AssetBundle加载的四种方式(补充 三,四)
来源:互联网 发布:网络整合营销4i原则 编辑:程序博客网 时间:2024/05/21 08:38
#region 第三种类型 /// <summary> /// 路径有本地和远程,本地可以加file:// 或者file:/// 路径要完整的本地路径,这个位置卡了很久,经过多次尝试得到最终正确的路径 /// </summary> /// <param name="path"></param> /// <returns></returns> /// //在Start方法中调用 参数为自己本地最终正确路径 //StartCoroutine(LoadFromCacheOrDownload(@"file://F:\PrivateForWCW\Unity\UGUI\AssetBudleProject\AssetBundle\scene\cubewall.unity3d")); /// 服务器上 StartCoroutine(LoadFromCacheOrDownload(@"http://localhost//AssetBundless/scene/cubewall.unity3d")); IEnumerator LoadFromCacheOrDownload(string path) { while (!Caching.ready) yield return null; WWW www = WWW.LoadFromCacheOrDownload(path, 1); yield return www; if (!string.IsNullOrEmpty(www.error)) { Debug.Log(www.error); yield break; } AssetBundle AB = www.assetBundle; GameObject obj=AB.LoadAsset<GameObject>("cube"); Instantiate(obj); } #endregion #region 第四种 UnityWebRequst //这个UnityWebRequst相当与取代了WWW这个类,还进一步优化了 //使用 UnityWebRequest 需要引入UnityEngine.Networking; IEnumerator LoadFormWebRequst() { string uri = @"http://localhost//AssetBundless/scene/cubewall.unity3d"; UnityWebRequest request = UnityWebRequest.GetAssetBundle(uri); yield return request.Send(); // AssetBundle AB = DownloadHandlerAssetBundle.GetContent(request); 第一种方式获取AssetBundle AssetBundle AB = (request.downloadHandler as DownloadHandlerAssetBundle).assetBundle;// 第二种方式获取AssetBundle GameObject obj = AB.LoadAsset<GameObject>("cube"); Instantiate(obj); } #endregion
阅读全文
0 0
- AssetBundle加载的四种方式(补充 三,四)
- AssetBundle加载的四种方式
- android: activitity 的四种加载方式
- Android Activity的四种加载方式
- Android的四种加载方式
- Pig加载配置的四种方式
- jquery 的四种加载方式
- Activity的四种加载方式
- Activity的四种加载方式
- Activity的四种加载方式
- jquery加载的四种方式
- 加载配置文件的四种方式
- 加载配置文件的四种方式
- 实现Action的三种方式(四)
- 实现微信布局的四种方式(三)
- Spring学习(四)-Bean的三种装配方式
- hibernate的懒加载的四种解决方式
- 加载CSS的四种方式以及CSS代码格式
- ftp相关
- 卷积与转置卷积
- mySQL转换字符编码的方法
- ^ & | ~ 位运算的再次说明
- JS追加日期时间格式化
- AssetBundle加载的四种方式(补充 三,四)
- Nginx设置防止IP及非配置域名访问
- java学习笔记
- word2vec 负采样思路
- ubuntu14.04下的openmp支持
- 百度外卖wifi小票打印机如何设置连接手机
- pipework给docker设置ip
- 浏览器CSS兼容问题汇总及解决
- 前端之webpack