加载AssetBundle
2014-09-11 17:51
127 查看
加载AssetBundle,使用www类加载
详细代码如下:
详细代码如下:
using UnityEngine; using System; using System.Collections; using System.IO; /// <summary> /// 动态加载模型的脚本 /// </summary> public class LoadModels : MonoBehaviour { /******************全部加载****************** private string BundleURL; private string[] _modelName; void Start() { _modelName = SingleXmlRead.GetInstance()._ModelName; BundleURL = "file://" + Application.streamingAssetsPath + "/models/modelsBundles.unity3d"; StartCoroutine(DownloadAssetAndScene()); } IEnumerator DownloadAssetAndScene() { //下载assetbundle, using (WWW asset = new WWW(BundleURL)) { yield return asset; AssetBundle bundle = asset.assetBundle; foreach(string _name in _modelName) { GameObject _myTransform ; _myTransform = Instantiate(bundle.Load(_name))as GameObject; _myTransform.transform.parent = transform; _myTransform.SetActive(false); } SingleFindObj.GetInstance()._modelsSelfRotation.enabled = true; bundle.Unload(false); yield return new WaitForSeconds(5); } } */ /******************单个加载******************/ public AnimationClip _down1,_down2,_up1,_up2; private string[] _bundleURL; void Start() { _bundleURL= SingleXmlRead.GetInstance()._ModelName; StartCoroutine(DownloadAssetAndScene()); } IEnumerator DownloadAssetAndScene() { //下载assetbundle, foreach( string _str in _bundleURL) { string _path = Application.streamingAssetsPath + "/models/"+ _str + ".unity3d"; if( !File.Exists(_path)) { continue; } using (WWW asset = new WWW("file://" + _path)) { yield return asset; AssetBundle bundle = asset.assetBundle; if(bundle.Contains(_str)) { GameObject _myTransform ; _myTransform = Instantiate(bundle.Load(_str))as GameObject; } bundle.Unload(false); } } SingleFindObj.GetInstance()._autoCtrl.enabled = true; Destroy(GetComponent<LoadModels>()); } }
相关文章推荐
- unity5 通过 WWW 加载 Assetbundle 中的 texture
- Unity3d 同步加载 Assetbundle 方法 AssetBundle.CreateFromFile
- AssetBundle 打包加载
- U3D lightmap的assetbundle和动态加载
- 关于unity中Assetbundle动态加载
- Assetbundle创建与加载
- Unity3D在移动平台下加载AssetBundle导致Shader效果不正确的问题
- Unity异步加载AssetBundle方案,4.x版本资源加载(5.x版本资源可以参考插件AssetBundleManager)
- Unity3D之AssetBundle【3】AssetBundle资源加载管理器
- 解决Unity 中WWW加载 AssetBundle---中文路径
- Unity 编辑器环境下不能正确加载Android Assetbundle 中的 Shader 解决方法
- Unity5.3.5的AssetBundle加载
- Unity5-ABSystem(三):AssetBundle加载
- Unity3d 同步加载 Assetbundle 方法 AssetBundle.CreateFromFile
- unity的assetbundle加载
- Unity3D之AssetBundle【4】简易AssetBundle打包、加载demo
- Unity3D基础学习之AssetBundle 资源包创建与加载
- Unity(五) Unity3D使用Assetbundle打包加载(Prefab、场景)转载原博客
- Unity游戏开发使用Assetbundle加载场景实战
- 【U3D】AssetBundle.CreateFromFile()加载资源失败