public UnityEngine.Object[] GetResources(string bundlePath, string resName) { //表示是否缓存了该物体 if (mAssetObjsDict.ContainsKey(bundlePath)) { AssetBundleObjs abObjs = mAssetObjsDict[bundlePath]; List <UnityEngine.Object> objs = abObjs.GetResObj(resName); if (objs != null) { return(objs.ToArray()); } } //表示已经加载过bundle if (mABRelationDict.ContainsKey(bundlePath)) { IABRelationManager iABRelation = mABRelationDict[bundlePath]; UnityEngine.Object[] objs = iABRelation.GetResources(resName); AssetObj assetObj = new AssetObj(objs); if (mAssetObjsDict.ContainsKey(bundlePath)) { AssetBundleObjs assetBundleObjs = mAssetObjsDict[bundlePath]; mAssetObjsDict.Add(bundlePath, assetBundleObjs); } else { AssetBundleObjs assetBundleObjs = new AssetBundleObjs(resName, assetObj); mAssetObjsDict.Add(bundlePath, assetBundleObjs); } return(objs); } return(null); }
/// <summary> /// 释放一个Bundle包里的一个资源 /// </summary> /// <param name="bundlePath"></param> /// <param name="resName"></param> public void DisposeResObj(string bundlePath, string resName) { if (mAssetObjsDict.ContainsKey(bundlePath)) { AssetBundleObjs assetBundleObjs = mAssetObjsDict[bundlePath]; assetBundleObjs.ReleaseResObj(resName); } }
/// <summary> /// 释放一个Bundle包里的所有资源 /// </summary> /// <param name="bundlePath"></param> public void DisposeResObjs(string bundlePath) { if (mAssetObjsDict.ContainsKey(bundlePath)) { AssetBundleObjs assetBundleObjs = mAssetObjsDict[bundlePath]; assetBundleObjs.ReleaseAllResObjs(); } Resources.UnloadUnusedAssets(); }