您的位置:首页 > 其它

AssetBundle-----资源加载(读取assetbundle)

2017-02-11 15:38 281 查看
using UnityEngine;using System.Collections;public class LoadAssetBundle : MonoBehaviour { public string path; public string file;void Start () { StartCoroutine(Load());} IEnumerator Load() { string _path ="file:///"+Application.dataPath + path;WWW www = WWW.LoadFromCacheOrDownload(_path,1); yield return www; AssetBundle bundle = www.assetBundle; AssetBundleRequest request = bundle.LoadAssetAsync(file); yield return request; GameObject obj = request.asset as GameObject; Instantiate(obj); bundle.Unload(false);www.Dispose(); }}
using System.Collections;using System.Collections.Generic;using UnityEngine;public class TEST : MonoBehaviour{// Use this for initializationvoid Start(){string path =Application.dataPath + "/bundles/aaaa";AssetBundle assetbundle = AssetBundle.LoadFromFile(path);GameObject g = assetbundle.LoadAsset<GameObject>("Cube");GameObject.Instantiate(g);}// Update is called once per framevoid Update(){}}

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: