private void Awake() { s_instance = this; DontDestroyOnLoad(gameObject); LoadManifest(); LoadBundleMap(); }
/// <summary> /// Load assetbundle manifest /// </summary> private void LoadAssetBundleManifest() { if (null != m_Manifest) { Object.DestroyImmediate(m_Manifest, true); m_Manifest = null; } m_AssetBundleNames.Clear(); LoadAssetBundle(ConstantData.assetBundleManifest, (data) => { AssetBundleCache abCache = data as AssetBundleCache; if (null != abCache) { m_Manifest = abCache.LoadAsset <AssetBundleManifest>("AssetBundleManifest"); } UnLoadAssetBundle(ConstantData.assetBundleManifest, true); if (null != m_Manifest) { string[] assetBundleNames = m_Manifest.GetAllAssetBundles(); m_AssetBundleNames.AddRange(assetBundleNames); } }, false, false, false); }
private void UpdateLoading() { try { if (this.isDone || FastLoadRequest.mLoadTime >= 0.00833333376795053) { return; } DateTime now1 = DateTime.Now; if (this.mAssetBundleNode != null) { this.mAssetBundle = AssetManager.Instance.OpenAssetBundleAndDependencies(this.mAssetBundleNode, 0, (List <AssetBundleCache>)null, 15f); this.mAsset = this.mAssetBundle.AssetBundle.LoadAsset(Path.GetFileNameWithoutExtension(this.mAssetName)); this.mAssetBundle = (AssetBundleCache)null; AssetManager.Instance.UnloadUnusedAssetBundles(true, false); } else { this.mAsset = Resources.Load(this.mAssetName, this.mAssetType); } DateTime now2 = DateTime.Now; FastLoadRequest.mLoadTime += (now2 - now1).TotalSeconds; FastLoadRequest.mRequests.Remove(this); this.mIsDone = true; this.UntrackTextComponents(this.mAsset); } catch (Exception ex) { Debug.Log((object)("Exception: LoadFile[" + this.mAssetName + "]" + ex.ToString())); FastLoadRequest.mRequests.Remove(this); this.mIsDone = true; } }
public AssetBundleLoadRequest(AssetBundleCache assetBundle, string assetName, System.Type assetType) { if (assetType.IsSubclassOf(typeof(Component))) { this.mComponentClass = assetType; } this.mAssetBundle = assetBundle; this.mLoadRequest = this.mAssetBundle.AssetBundle.LoadAssetAsync(assetName); }
public AssetBundleCache OpenAssetBundleAndDependencies(AssetList.Item node, int refCount = 1, List <AssetBundleCache> result = null, float expireTime = 0.0f) { if (this.mAssetBundles.Count + (1 + node.Dependencies.Length) > AssetManager.MaxAssetBundles) { this.UnloadUnusedAssetBundles(true, true); } AssetBundleCache assetBundleCache1 = this.OpenAssetBundle(node.IDStr, (node.Flags & AssetBundleFlags.Persistent) != (AssetBundleFlags)0, false); if (assetBundleCache1 == null) { return((AssetBundleCache)null); } assetBundleCache1.AddReferencer(refCount); if (result != null) { result.Add(assetBundleCache1); } this.OpenScriptAssetBundle(); bool flag1 = false; bool flag2 = false; if (assetBundleCache1.Dependencies == null) { assetBundleCache1.Dependencies = new AssetBundleCache[node.Dependencies.Length + 1]; assetBundleCache1.Dependencies[assetBundleCache1.Dependencies.Length - 1] = assetBundleCache1; flag2 = true; } for (int index = 0; index < node.Dependencies.Length; ++index) { AssetList.Item dependency = node.Dependencies[index]; AssetBundleCache assetBundleCache2 = this.OpenAssetBundle(dependency.IDStr, (dependency.Flags & AssetBundleFlags.Persistent) != (AssetBundleFlags)0, false); if (flag2) { assetBundleCache1.Dependencies[index] = assetBundleCache2; } if (assetBundleCache2 != null) { if (assetBundleCache2.NumReferencers == 0) { assetBundleCache2.ExpireTime = expireTime; } if (result != null) { result.Add(assetBundleCache2); } assetBundleCache2.AddReferencer(refCount); } flag1 |= assetBundleCache2 == null; } if (flag1) { DebugUtility.LogError("Error occurred when opening '" + ((Object)this).get_name() + "'"); } return(assetBundleCache1); }
/// <summary> /// 添加 assetbundle 缓存 /// </summary> /// <param name="name"></param> /// <param name="assetBundle"></param> /// <param name="persistent"></param> /// <param name="refCount"></param> /// <returns></returns> private AssetBundleCache AddAssetBundleCache(string name, AssetBundle assetBundle, bool persistent, int refCount) { AssetBundleCache assetBundleCache; if (!m_AssetBundleCaches.TryGetValue(name, out assetBundleCache)) { assetBundleCache = new AssetBundleCache(name, assetBundle, persistent, refCount); m_AssetBundleCaches.Add(name, assetBundleCache); } return(assetBundleCache); }
private void DrawSearchTarget() { EditorGUILayout.Space(); UnityEngine.GameObject newTarget = EditorGUILayout.ObjectField("搜索GameObject资源:", mShowTarget, typeof(GameObject), true) as GameObject; if (mShowTarget != newTarget) { mShowTarget = newTarget; } if (mShowTarget != null) { EditorGUILayout.Space(); AssetCache cache = AssetCacheManager.Instance.FindInstGameObjectCache(mShowTarget); if (cache != null) { EditorGUILayout.TextField(cache.RefCount.ToString()); AssetBundleCache bundleCache = cache as AssetBundleCache; if (bundleCache != null) { AssetInfo assetInfo = bundleCache.Target; if (assetInfo != null) { for (int i = 0; i < assetInfo.DependFileCount; ++i) { string dependFileName = assetInfo.GetDependFileName(i); if (!string.IsNullOrEmpty(dependFileName)) { AssetLoader loader = ResourceMgr.Instance.AssetLoader as AssetLoader; if (loader != null) { AssetInfo dependAssetInfo = loader.FindAssetInfo(dependFileName); if (dependAssetInfo != null && dependAssetInfo.Cache != null) { string dependKey = GetBundleKey(dependFileName); EditorGUILayout.LabelField(dependKey); EditorGUILayout.TextField(dependAssetInfo.Cache.RefCount.ToString()); } } } } } } EditorGUILayout.Space(); EditorGUILayout.Space(); } } }
internal override void OnLoadFinish() { ////Logx.Logz("AssetBundleLoader OnLoadFinish : " + this.path); //ab 加载完成 AssetBundleCache abCache = new AssetBundleCache(); abCache.path = path; abCache.finishLoadCallback = finishLoadCallback; abCache.RefCount = this.refCount; abCache.assetBundle = abCreateReq.assetBundle; //abCache.ab = ab //finishLoadCallback?.Invoke(abCache); AssetBundleManager.Instance.OnLoadFinish(abCache); }
private bool IsAssetBundleLoading(AssetBundleCache abc) { for (int index = 0; index < this.mLoadingAssets.Count; ++index) { if (this.mLoadingAssets[index].AssetBundles != null && this.mLoadingAssets[index].AssetBundles.Contains(abc)) { return(true); } } for (int index = 0; index < this.mScenes.Count; ++index) { if (this.mScenes[index].Request != null && this.mScenes[index].AssetBundles.Contains(abc)) { return(true); } } return(false); }
public ResourceManager() { if (ConstantData.enableCache) { Caching.compressionEnabled = false; string path = ConstantData.unpackPath; FileUtil.CreateDirectory(path); UnityEngine.Cache cache = Caching.GetCacheByPath(path); if (!cache.valid) { cache = Caching.AddCache(path); } Caching.currentCacheForWriting = cache; } else { if (ConstantData.enablePatch) { AddSearchPath(ConstantData.patchPath); } if (ConstantData.enableCustomCompress) { AddSearchPath(ConstantData.unpackPath); } } m_task = new LoaderTask(); m_cache = new AssetBundleCache(m_task); m_downloadOrCache = new DownloadOrCache(); Clear(); if (ConstantData.enableAssetBundle) { LoadVersion(); } }
IEnumerator RealLoadAssetBundle(AssetBundleCache abCache) { //foreach(string path in FilePathDefine.loadedPath){ var paths = FilePathDefine.loadedPath; var _path = Path.Combine(paths[0], ALG.EncodeBundleName(abCache.Name)); if (!File.Exists(_path)) { _path = Path.Combine(paths[1], ALG.EncodeBundleName(abCache.Name)); } var bundleLoadRequest = AssetBundle.LoadFromFileAsync(_path); yield return(bundleLoadRequest); var myLoadedAssetBundle = bundleLoadRequest.assetBundle; abCache.Target = myLoadedAssetBundle; abCache.LoadAssetSuccessCallback(myLoadedAssetBundle); abCache.isLock = false; //} }
public void UnloadUnusedAssetBundles(bool immediate = false, bool forceUnload = false) { bool flag = false; for (int index = this.mAssetBundles.Count - 1; index >= 0; --index) { AssetBundleCache mAssetBundle = this.mAssetBundles[index]; if (!mAssetBundle.Persistent && (mAssetBundle.NumReferencers <= 0 || forceUnload) && ((immediate || (double)mAssetBundle.ExpireTime >= 15.0) && !this.IsAssetBundleLoading(mAssetBundle))) { mAssetBundle.Unload(); this.mAssetBundles.RemoveAt(index); flag = true; } } if (!flag) { return; } GC.Collect(); GC.WaitForPendingFinalizers(); }
IEnumerator Start() { var assetBundleUrl = "http://localhost:8080/AssetBundles/"; var assetBundleManager = AssetBundleManager.Instance; var yieldConnectToServer = assetBundleManager.ConnectToServer(assetBundleUrl) .OnErrorRetry <Unit, UnityWebRequestErrorException>(e => Debug.LogError(e.Message), TimeSpan.FromSeconds(5)) .ToYieldInstruction(); yield return(yieldConnectToServer); Debug.Log("CacheSize: " + AssetBundleCache.GetCacheSize()); var assetBundleName = "cube"; var assetName = "Cube"; var yieldDownloadCube = assetBundleManager.GetAsset <GameObject>(assetBundleName, assetName, new ConsoleProgress()).ToYieldInstruction(); yield return(yieldDownloadCube); Instantiate(yieldDownloadCube.Result); Debug.Log("CacheSize: " + AssetBundleCache.GetCacheSize()); }
public override void LoadAssetBundle(string name, Action <AssetBundle> success, Action err) { var abCache = abPool.Spawn(name); if (null == abCache) { abCache = new AssetBundleCache(name, null); abPool.Add(name, abCache); } else if (!abCache.isLock) { success(abCache.Target); return; } abCache.LoadAssetSuccessCallback += success; abCache.LoadAssetFailCallback += err; if (!abCache.isLock) { abCache.isLock = true; var task = TaskManager.CreateTask(RealLoadAssetBundle(abCache), "AssetBundle_" + name); task.Start(); } }
protected override BaseAssetCache CreateAssetCache <T>(AssetCacheType AssetType, string AssetPath) { BaseAssetCache Cache = null; switch (AssetType) { case AssetCacheType.Asset: Cache = new AssetBundleCache <UnityEngine.Object>(AssetType, AssetPath, Manifest_); break; case AssetCacheType.Prefab: Cache = new PrefabAssetBundleCache(AssetType, AssetPath, Manifest_); break; case AssetCacheType.Data: Cache = new DataAssetBundleCache(AssetType, AssetPath, Manifest_); break; default: break; } return(Cache); }
public void LoadAssetFromBundle(string path, string name, System.Type type, UnityAction <object> callback, bool async, bool persistent, bool unload = false) { string fullPath = path; if (!path.EndsWith(ConstantData.abExtend)) { fullPath = string.Format("{0}{1}", path, ConstantData.abExtend); } fullPath = fullPath.ToLower(); LoadAssetBundle(fullPath, (data) => { AssetBundleCache cache = data as AssetBundleCache; Object asset = null; if (null != cache && !string.IsNullOrEmpty(name)) { asset = cache.LoadAsset(name, type); } if (null == asset) { UnityEngine.Debug.LogFormat("[LoadManager.LoadAssetFromBundle], path: {0}, name : {1}, asset is null", path, name); } if (null != callback) { callback(asset); } if (unload) { UnLoadAssetBundle(path); } }, async, persistent); }
// changed is return true bool UpdateAssetRefMap() { bool ret = false; // used list var list = AssetCacheManager.Instance.UsedCacheList; if (list.Count != mUsedAssetRefMap.Count) { ret = true; } HashSet <string> hash = new HashSet <string> (); HashSet <string> removeHash = new HashSet <string> (); var node = list.First; while (node != null) { AssetCache cache = node.Value; if (cache != null) { AssetBundleCache bundleCache = cache as AssetBundleCache; if ((bundleCache != null) && (bundleCache.Target != null)) { string key = GetBundleKey(bundleCache.Target.FileName); hash.Add(key); if (mUsedAssetRefMap.ContainsKey(key)) { if (mUsedAssetRefMap[key] != cache.RefCount) { mUsedAssetRefMap[key] = cache.RefCount; ret = true; } } else { mUsedAssetRefMap.Add(key, cache.RefCount); ret = true; } } else { ResourceAssetCache resCache = cache as ResourceAssetCache; if ((resCache != null) && (resCache.Target != null)) { string key = StringHelper.Format("Res:{0}", resCache.Target.name); hash.Add(key); if (mUsedAssetRefMap.ContainsKey(key)) { if (mUsedAssetRefMap[key] != cache.RefCount) { mUsedAssetRefMap[key] = cache.RefCount; ret = true; } } else { mUsedAssetRefMap.Add(key, cache.RefCount); ret = true; } } } } node = node.Next; } var iter = mUsedAssetRefMap.GetEnumerator(); while (iter.MoveNext()) { string key = iter.Current.Key; if (!hash.Contains(key)) { removeHash.Add(key); } } iter.Dispose(); var removeIter = removeHash.GetEnumerator(); while (removeIter.MoveNext()) { mUsedAssetRefMap.Remove(removeIter.Current); } removeIter.Dispose(); hash.Clear(); removeHash.Clear(); // not used list list = AssetCacheManager.Instance.NotUsedCacheList; if (list.Count != mNotUsedAssetRefMap.Count) { ret = true; } node = list.First; while (node != null) { AssetCache cache = node.Value; if (cache != null) { AssetBundleCache bundleCache = cache as AssetBundleCache; if ((bundleCache != null) && (bundleCache.Target != null)) { string key = GetBundleKey(bundleCache.Target.FileName); hash.Add(key); if (mNotUsedAssetRefMap.ContainsKey(key)) { if (mNotUsedAssetRefMap[key] != cache.RefCount) { mNotUsedAssetRefMap[key] = cache.RefCount; ret = true; } } else { mNotUsedAssetRefMap.Add(key, cache.RefCount); ret = true; } } else { ResourceAssetCache resCache = cache as ResourceAssetCache; if ((resCache != null) && (resCache.Target != null)) { string key = StringHelper.Format("Res:{0}", resCache.Target.name); hash.Add(key); if (mNotUsedAssetRefMap.ContainsKey(key)) { if (mNotUsedAssetRefMap[key] != cache.RefCount) { mNotUsedAssetRefMap[key] = cache.RefCount; ret = true; } } else { mNotUsedAssetRefMap.Add(key, cache.RefCount); ret = true; } } } } node = node.Next; } iter = mNotUsedAssetRefMap.GetEnumerator(); while (iter.MoveNext()) { string key = iter.Current.Key; if (!hash.Contains(key)) { removeHash.Add(key); } } iter.Dispose(); removeIter = removeHash.GetEnumerator(); while (removeIter.MoveNext()) { mNotUsedAssetRefMap.Remove(removeIter.Current); } removeIter.Dispose(); hash.Clear(); removeHash.Clear(); return(ret); }
private LoadRequest InternalLoadAsync(string name, System.Type type) { string localizedObjectName = AssetManager.GetLocalizedObjectName(name, false); if (name != localizedObjectName) { if (GameUtility.Config_UseAssetBundles.Value) { AssetList.Item itemByPath = AssetManager.AssetList.FindItemByPath(localizedObjectName); if (itemByPath != null && itemByPath.Exist) { name = localizedObjectName; } } else { name = localizedObjectName; } } AssetManager.ManagedAsset managedAsset = (AssetManager.ManagedAsset)null; bool flag = true; int hashCode = name.GetHashCode(); for (int index = this.mLoadingAssets.Count - 1; index >= 0; --index) { if (this.mLoadingAssets[index].HashCode == hashCode && (object)this.mLoadingAssets[index].AssetType == (object)type && this.mLoadingAssets[index].Name == name) { return((LoadRequest)this.mLoadingAssets[index].Request_Weak.Target); } } for (int index = this.mAssets.Count - 1; index >= 0; --index) { managedAsset = this.mAssets[index]; if (managedAsset.HashCode == hashCode && (object)managedAsset.AssetType == (object)type && managedAsset.Name == name) { if (managedAsset.Asset.IsAlive && Object.op_Inequality(managedAsset.Asset.Target, (Object)null)) { return((LoadRequest) new ResourceLoadRequest(managedAsset.Asset.Target)); } this.mAssets.RemoveAt(index); flag = false; break; } } if (flag) { managedAsset = new AssetManager.ManagedAsset(); managedAsset.Name = name; managedAsset.HashCode = hashCode; managedAsset.AssetType = type; } AssetList.Item itemByPath1 = AssetManager.AssetList.FindItemByPath(name); LoadRequest loadRequest; if (itemByPath1 == null) { loadRequest = !type.IsSubclassOf(typeof(Texture)) ? (LoadRequest) new ResourceLoadRequest(Resources.LoadAsync(name, type)) : (LoadRequest) new FastLoadRequest((AssetList.Item)null, name, type); } else if (type.IsSubclassOf(typeof(Texture))) { loadRequest = (LoadRequest) new FastLoadRequest(itemByPath1, name, type); } else { managedAsset.AssetBundles = new List <AssetBundleCache>(); AssetBundleCache assetBundle = this.OpenAssetBundleAndDependencies(itemByPath1, 1, managedAsset.AssetBundles, 0.0f); if (assetBundle == null) { loadRequest = (LoadRequest) new ResourceLoadRequest((Object)null); managedAsset.HasError = true; } else { string withoutExtension = Path.GetFileNameWithoutExtension(name); loadRequest = (LoadRequest) new AssetBundleLoadRequest(assetBundle, withoutExtension, type); } } managedAsset.Request_Weak = new WeakReference((object)loadRequest); managedAsset.Request_Strong = loadRequest; this.mLoadingAssets.Add(managedAsset); return(loadRequest); }
void RefMapUpdate() { if (!Application.isPlaying) { return; } float curTime = Time.unscaledTime; m_IsUPdateData = curTime - m_LastUpdateTime > 0.25f; if (m_IsUPdateData) { m_LastUpdateTime = curTime; } if (m_IsUPdateData) { bool isChg = UpdateAssetRefMap(); int cnt = TimerMgr.Instance.TimerPoolCount; if (cnt != m_LastTimeCnt) { m_LastTimeCnt = cnt; isChg = true; } cnt = ResourceAssetCache.GetPoolCount(); if (cnt != m_LastResCacheCnt) { m_LastResCacheCnt = cnt; isChg = true; } cnt = AssetBundleCache.GetPoolCount(); if (cnt != m_LastBundleCacheCnt) { m_LastBundleCacheCnt = cnt; isChg = true; } #if UNITY_5_3 || UNITY_5_4 || UNITY_5_5 || UNITY_5_6 || UNITY_2018 || UNITY_2019 cnt = BundleCreateAsyncTask.GetPoolCount(); if (cnt != m_LastBundleCreateCnt) { m_LastBundleCreateCnt = cnt; isChg = true; } #endif cnt = WWWFileLoadTask.GetPoolCount(); if (cnt != m_LastWWWCreateCnt) { m_LastWWWCreateCnt = cnt; isChg = true; } cnt = HttpHelper.RunCount; if (cnt != m_LastRunHttpCnt) { m_LastRunHttpCnt = cnt; isChg = true; } cnt = HttpHelper.PoolCount; if (cnt != m_LastHttpPoolCnt) { m_LastHttpPoolCnt = cnt; isChg = true; } if (isChg) { this.Repaint(); } } }
public Object InternalLoad(string name, System.Type type) { AssetManager.ManagedAsset managedAsset = (AssetManager.ManagedAsset)null; string localizedObjectName = AssetManager.GetLocalizedObjectName(name, false); if (name != localizedObjectName) { if (GameUtility.Config_UseAssetBundles.Value) { AssetList.Item itemByPath = AssetManager.AssetList.FindItemByPath(localizedObjectName); if (itemByPath != null && itemByPath.Exist) { name = localizedObjectName; } } else { name = localizedObjectName; } } int hashCode = name.GetHashCode(); for (int index = this.mLoadingAssets.Count - 1; index >= 0; --index) { if (this.mLoadingAssets[index].HashCode == hashCode && (object)this.mLoadingAssets[index].AssetType == (object)type && this.mLoadingAssets[index].Name == name) { managedAsset = this.mLoadingAssets[index]; this.mLoadingAssets.RemoveAt(index); this.mAssets.Add(managedAsset); managedAsset.Request_Weak = new WeakReference((object)managedAsset.Request_Strong); managedAsset.Request_Strong = (LoadRequest)null; managedAsset.Request = new WeakReference((object)managedAsset.Request2); managedAsset.Request2 = (WeakReference)null; break; } } if (managedAsset == null) { for (int index = this.mAssets.Count - 1; index >= 0; --index) { managedAsset = this.mAssets[index]; if (managedAsset.HashCode == hashCode && (object)managedAsset.AssetType == (object)type && managedAsset.Name == name) { if (managedAsset.Asset.IsAlive) { Object target = managedAsset.Asset.Target; if (Object.op_Inequality(target, (Object)null)) { return(target); } } if (managedAsset.HasError) { return((Object)null); } break; } managedAsset = (AssetManager.ManagedAsset)null; } } if (managedAsset == null) { managedAsset = new AssetManager.ManagedAsset(); managedAsset.Name = name; managedAsset.AssetType = type; managedAsset.HashCode = hashCode; this.mAssets.Add(managedAsset); } AssetList.Item itemByPath1 = AssetManager.AssetList.FindItemByPath(name); if (itemByPath1 == null) { managedAsset.Asset = AssetManager.ObjectRef <Object> .CreateWeakRef(Resources.Load(name, type)); } else { AssetBundleCache assetBundleCache = this.OpenAssetBundleAndDependencies(itemByPath1, 0, (List <AssetBundleCache>)null, 0.0f); if (assetBundleCache != null) { string withoutExtension = Path.GetFileNameWithoutExtension(name); Object @object = !type.IsSubclassOf(typeof(Component)) ? assetBundleCache.AssetBundle.LoadAsset(withoutExtension, type) : (Object)((GameObject)assetBundleCache.AssetBundle.LoadAsset(withoutExtension)).GetComponent(type); managedAsset.Asset = AssetManager.ObjectRef <Object> .CreateStrongRef(@object); managedAsset.Asset = AssetManager.ObjectRef <Object> .CreateWeakRef(@object); } else { managedAsset.Asset = AssetManager.ObjectRef <Object> .CreateStrongRef((Object)null); } } managedAsset.HasError = Object.op_Equality(managedAsset.Asset.Target, (Object)null); if (managedAsset != null) { return(managedAsset.Asset.Target); } return((Object)null); }
private AssetBundleCache OpenAssetBundle(string assetbundleID, bool persistent = false, bool isDependency = false) { AssetList.Item itemById = AssetManager.AssetList.FindItemByID(assetbundleID); if (itemById == null) { DebugUtility.LogError("AssetBundle not found: " + assetbundleID); return((AssetBundleCache)null); } for (int index = 0; index < this.mAssetBundles.Count; ++index) { if (this.mAssetBundles[index].Name == assetbundleID) { return(this.mAssetBundles[index]); } } if (this.mAssetBundles.Count >= AssetManager.MaxAssetBundles) { this.UnloadUnusedAssetBundles(true, true); } string path = AssetDownloader.CachePath + assetbundleID; if (!File.Exists(path)) { DebugUtility.LogError("AssetBundle doesn't exist: " + assetbundleID); return((AssetBundleCache)null); } if ((itemById.Flags & AssetBundleFlags.RawData) != (AssetBundleFlags)0) { DebugUtility.LogError("AssetBundle is RawData: " + assetbundleID); return((AssetBundleCache)null); } AssetBundle ab; if ((itemById.Flags & AssetBundleFlags.Compressed) != (AssetBundleFlags)0) { int size; IntPtr num = NativePlugin.DecompressFile(path, out size); if (num == IntPtr.Zero) { DebugUtility.LogError("Failed to decompress AssetBundle: " + assetbundleID); return((AssetBundleCache)null); } byte[] destination = new byte[size]; Marshal.Copy(num, destination, 0, size); NativePlugin.FreePtr(num); ab = AssetBundle.LoadFromMemory(destination); if (Object.op_Equality((Object)ab, (Object)null)) { DebugUtility.LogError("Failed to create AssetBundle from memory: " + assetbundleID); } } else { ab = AssetBundle.LoadFromFile(path); if (Object.op_Equality((Object)ab, (Object)null)) { DebugUtility.LogError("Failed to open AssetBundle: " + assetbundleID); } } AssetBundleCache assetBundleCache = new AssetBundleCache(assetbundleID, ab); this.mAssetBundles.Add(assetBundleCache); assetBundleCache.Persistent = persistent; return(assetBundleCache); }
/// <summary> /// 初期化. /// </summary> public void Init(string saveDir, uint capacity) { m_cache = new AssetBundleCache <T>(saveDir, capacity); }