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(){}}
相关文章推荐
- Unity资源处理机制(Assets/WWW/AssetBundle/...)读取和加载资源方式详解
- Unity资源处理机制(Assets/WWW/AssetBundle/...)读取和加载资源方式详解
- Unity资源处理机制(Assets/WWW/AssetBundle/...)读取和加载资源方式详解
- 【Unity3d】关于AssetBundle.CreateFromFile()方法加载资源失败解决方法
- Unity3D之AssetBundle资源加载封装
- Unity3D基础学习之AssetBundle 资源包创建与加载
- Unity3D引擎WWW资源加载和缓存(AssetBundle、Texture、Audio)
- 详谈 Unity3D AssetBundle 资源加载,结合实际项目开发实例
- Unity3D之AssetBundle资源加载封装
- Unity3D 关于资源加载(Resources和AssetBundle)和内存管
- AssetBundle——外部加载资源Asset
- Unity3D之AssetBundle【3】AssetBundle资源加载管理器
- 【U3D】AssetBundle.CreateFromFile()加载资源失败
- Unity中 BundleAsset资源的打包和解析加载
- Unity3D基础学习之AssetBundle 资源包创建与加载
- Unity5系列资源管理AssetBundle——加载
- AssetBundle系列——资源的加载、简易的资源管理器
- 关于unity 中使用AssetBundle加载资源,shader偶尔会丢失的问题解决办法
- unity AssetBundle 加载资源 笔记
- AssetBundle加载资源的过程