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 initialization void 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 frame void Update() { } }
AssetBundle-----资源加载(读取assetbundle)
最新推荐文章于 2024-07-07 12:38:17 发布