当前位置: 首页 > news >正文

玉林网站推广广告制作公司怎么拉业务

玉林网站推广,广告制作公司怎么拉业务,seo专业培训,校园宿舍网网络设计案例1.新建两个预制体: Cube1:GameObject Material1:Material Cube1使用了Material1材质 之后设置打包配置 Cube1的打包配置为custom.ab Material1的打包配置为mat.ab 2.在Asset文件夹下创建Editor文件夹,并在Editor下创建BuildBundle…

1.新建两个预制体:

Cube1:GameObject

Material1:Material

Cube1使用了Material1材质

之后设置打包配置

Cube1的打包配置为custom.ab

Material1的打包配置为mat.ab

2.在Asset文件夹下创建Editor文件夹,并在Editor下创建BuildBundles.cs

using System.IO;

using UnityEditor;

using UnityEngine;

public class BuildBundles : Editor

{

[MenuItem("Custom/BuildBundles")]

static void BuildBundle()

{

//参数(打包路径、选项为None、使用平台)

BuildPipeline.BuildAssetBundles(Path.Combine(Application.dataPath + "/AssetBundle"), BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);

}

}

创建完成后,可在工具栏看到Custom/BuildBundles选项

3.将预制体打包成AssetBundle文件

在Asset文件夹下创建AssetBundle文件夹

之后点击工具栏的Custom/BuildBundles,AssetBundle文件被生成至AssetBundle文件夹中

AssetBundle是本次生成的所有的AssetBundle文件的配置文件,其中的AssetBundleManifest属性描述了文件的信息和依赖关系

custom.ab为Cube1的配置信息,上面也说明了其与mat.ab有依赖关系

以下是mat.ab的配置信息

4.获取AssetBundle文件并编译至场景中

新建AssetBundleTest.cs,并挂载至场景内任何一物体中

using System.Collections;

using System.IO;

using UnityEngine;

using UnityEngine.Networking;

public class AssetBundleTest : MonoBehaviour

{

// Start is called before the first frame update

void Start()

{

//loadMat();//同步加载(依赖)

//loadCube();//同步加载(Cube)

StartCoroutine(LoadCubeAsync());//异步加载

//StartCoroutine(LoadCubeWWW());//从服务端获取

}

//加载依赖(同步)

void loadMat()

{

//加载依赖

//读取AssetBundle下名称为AssetBundle的文件

string path = Application.dataPath + "/AssetBundle/AssetBundle";

AssetBundle assetBundle = AssetBundle.LoadFromFile(path);

//加载该文件夹里的配置信息

AssetBundleManifest assetBundleManifest = assetBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");

//加载名为custom.ab的文件的所有依赖并转为字符串数组

string[] strs = assetBundleManifest.GetAllDependencies("custom.ab");

foreach(string name in strs)

{

//加载出需要用到的AssetBundle文件

AssetBundle.LoadFromFile(Application.dataPath + "/AssetBundle/" + name);

}

}

//加载Cube(同步)

void loadCube()

{

string Cubepath = Path.Combine(Application.dataPath + "/AssetBundle/custom.ab");

AssetBundle ab = AssetBundle.LoadFromFile(Cubepath);

GameObject CubePre = ab.LoadAsset<GameObject>("Cube");

Instantiate(CubePre);

}

//异步加载Cube

private IEnumerator LoadCubeAsync()

{

//加载依赖

//读取AssetBundle下名称为AssetBundle的文件

string path1 = Application.dataPath + "/AssetBundle/AssetBundle";

AssetBundleCreateRequest assetBundle1 = AssetBundle.LoadFromFileAsync(path1);

yield return assetBundle1;

//加载该文件夹里的配置信息

AssetBundleManifest assetBundleManifest = assetBundle1.assetBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");

//加载名为custom.ab的文件的所有依赖并转为字符串数组

string[] strs = assetBundleManifest.GetAllDependencies("custom.ab");

foreach (string name in strs)

{

//加载出需要用到的AssetBundle文件

AssetBundle.LoadFromFile(Application.dataPath + "/AssetBundle/" + name);

}

//加载Cube

//读取custom.ab文件

string path = Application.dataPath + "/AssetBundle/custom.ab";

//string path4 = Path.Combine(Application.dataPath, "AssetBundle", "custom.ab");//使用Path.Combine拼接路径

AssetBundleCreateRequest assetBundleCreateRequest = AssetBundle.LoadFromFileAsync(path);

//异步等待加载完成

yield return assetBundleCreateRequest;

//加载完成,之后在场景中生成出来

AssetBundle assetBundle = assetBundleCreateRequest.assetBundle;

GameObject CubePre = assetBundle.LoadAsset<GameObject>("Cube1");

Instantiate(CubePre);

}

private IEnumerator LoadCubeWWW()

{

//从服务端获取AssetBundle文件

//获取路径并通过UnityWebRequest获取指定文件

string path1 = Path.Combine("http://192.168.0.102/web/custom.ab");

UnityWebRequest unityWebRequest = UnityWebRequest.Get(path1);

//等待文件获取完成

yield return unityWebRequest.SendWebRequest();

//加载完成

AssetBundle assetBundle = DownloadHandlerAssetBundle.GetContent(unityWebRequest);

GameObject CubePre = assetBundle.LoadAsset<GameObject>("Cube");

Instantiate(CubePre);

}

}

http://www.dtcms.com/a/475963.html

相关文章:

  • 做渠道的网站有哪些方面wordpress加载 jquery
  • 黄石网站建设报价群辉nas 做网站
  • 建设银行手机银行网站登录三个律师做网站合适吗
  • 好模板网站wordpress openload
  • 动漫网站设计理念中国产品设计网
  • 西安建设门户网站购物网站导航素材代码
  • 西安商城类网站制作西安建设厅网站首页
  • 新蔡县城乡建设局网站dw网站制作
  • 网站支付页面设计page做网站
  • 绍兴网站开发08keji深圳装饰装修公司
  • 邱县网站建设近两年成功的网络营销案例及分析
  • 沈阳网站seo排名优化嘉兴注册公司
  • 做网站维护工作难吗免费行情网站链接
  • 网站建设平台官网河间米各庄互联网上网络营销的推广
  • 湖南seo网站多少钱天津网站建设需要多少钱
  • 网站建设国风网络公司wordpress猜你喜欢功能
  • 百度搜索网站怎么做网站可以给pdf做笔记
  • 曲靖住房和城乡建设局网站建设工程施工合同 示范文本
  • 海南网站建设fwlit软件开发模型包括哪些
  • VMWare和物理机之间文件传输
  • 自助建网站系统看电影工业厂房设计
  • 网页制作与网站建设从入门到精通 下载网站改版 总结
  • 定制型网站建设推广redis wordpress 提速
  • 最好的商业网站化妆培训网站 源码
  • 华为ENSP——OSPF的基本配置实验
  • 网站建设公司如何企业网站群建设的原因
  • 万网没备案怎么做网站自己怎么做网站赚钱吗
  • 制作网站地图软件开发定制app
  • 网站建设先进技术手机app制作公司郑州
  • 手机短视频网站的建设模型网站