protected virtual void LoadAssetAsync <T>(AssetCacheType AssetType, string AssetPath, Action <bool> Callback = null) where T : UnityEngine.Object { AssetPath = AssetPath.ToLower(); if (AssetCacheExisted(AssetPath)) { Callback?.Invoke(true); return; } if (!AssetLoadCallbackList_.ContainsKey(AssetPath)) { AssetLoadCallbackList_.Add(AssetPath, new List <Action <bool> > { Callback }); LoadAssetCacheCompletedAsync <T>(AssetType, AssetPath, (IsLoaded) => { foreach (var LoadCallback in AssetLoadCallbackList_[AssetPath]) { LoadCallback?.Invoke(IsLoaded); } AssetLoadCallbackList_.Remove(AssetPath); }); } else { AssetLoadCallbackList_[AssetPath].Add(Callback); } }
protected BaseAssetBundleCache(AssetCacheType AssetType, string AssetPath, UnityEngine.AssetBundleManifest Manifest) : base(AssetType, AssetPath) { this.Manifest_ = Manifest; this.Request_ = null; this.Bundle_ = null; }
protected BaseAssetCache(AssetCacheType AssetType, string AssetPath) { this.AssetType = AssetType; this.AssetPath = AssetPath; this.IsLoad = false; this.RefCount_ = 0; this.DependenciesCache_ = new List <BaseAssetCache>(); }
protected override BaseAssetCache LoadAssetSync <T>(AssetCacheType AssetType, string AssetPath) { AssetPath = AssetPath.ToLower(); if (!AssetBundlePathList_.Contains(AssetPath)) { return(null); } return(base.LoadAssetSync <T>(AssetType, AssetPath)); }
protected virtual BaseAssetCache LoadAssetSync <T>(AssetCacheType AssetType, string AssetPath) where T : UnityEngine.Object { AssetPath = AssetPath.ToLower(); if (AssetCacheExisted(AssetPath)) { return(AssetCacheList_[AssetPath]); } return(LoadAssetCacheCompletedSync <T>(AssetType, AssetPath)); }
protected override void LoadAssetAsync <T>(AssetCacheType AssetType, string AssetPath, LiteAction <bool> Callback = null) { AssetPath = AssetPath.ToLower(); if (!AssetBundlePathList_.Contains(AssetPath)) { Callback?.Invoke(false); return; } base.LoadAssetAsync <T>(AssetType, AssetPath, Callback); }
private BaseAssetCache LoadAssetCacheCompletedSync <T>(AssetCacheType AssetType, string AssetPath) where T : UnityEngine.Object { var Cache = CreateAssetCache <T>(AssetType, AssetPath); if (Cache == null) { return(null); } AssetCacheList_.Add(AssetPath, Cache); LoadAssetCacheDependenciesSync <T>(Cache); return(LoadAssetCacheSync <T>(Cache)); }
public static int constructor(IntPtr l) { int result; try { AssetCacheType o = new AssetCacheType(); LuaObject.pushValue(l, true); LuaObject.pushValue(l, o); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static void Preload(AssetCacheType type, string path) { path = Utils.ConvertPathSeparator(path); // Debug.LogFormat("Preload {0}:{1}", type, path); var cache = Current.cachedAssets[type]; if (cache.ContainsKey(path)) { cache[path].count++; } else { // Debug.LogFormat("Add cache {0}:{1}", type, path); var localizedPath = TryGetLocalizedPath(path); cache[path] = new CachedAssetEntry { count = 1, request = Resources.LoadAsync(localizedPath) }; } }
public static void Unpreload(AssetCacheType type, string path) { path = Utils.ConvertPathSeparator(path); // Debug.LogFormat("Unpreload {0}:{1}", type, path); var cache = Current.cachedAssets[type]; if (cache.ContainsKey(path)) { var entry = cache.GetNoTouch(path); entry.count--; if (entry.count <= 0) { // Debug.LogFormat("Remove cache {0}:{1}", type, path); cache.Remove(path); } } else { Debug.LogWarningFormat("Nova: Asset {0}:{1} not cached when unpreloading.", type, path); } }
private void LoadAssetCacheCompletedAsync <T>(AssetCacheType AssetType, string AssetPath, Action <bool> Callback = null) where T : UnityEngine.Object { var Cache = CreateAssetCache <T>(AssetType, AssetPath); if (Cache == null) { Callback?.Invoke(false); return; } AssetCacheList_.Add(AssetPath, Cache); LoadAssetCacheDependenciesAsync <T>(Cache, (IsLoaded) => { if (!IsLoaded) { Callback?.Invoke(false); return; } TaskManager.AddTask(LoadAssetCacheAsync <T>(Cache), () => { Callback?.Invoke(true); }); }); }
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); }
protected BaseAssetInternalCache(AssetCacheType AssetType, string AssetPath) : base(AssetType, AssetPath) { this.Bundle = null; }
public PrefabAssetInternalCache(AssetCacheType BundleType, string AssetPath) : base(BundleType, AssetPath) { AssetList_ = new Dictionary <string, UnityEngine.GameObject>(); AssetInstanceIDList_ = new List <int>(); }
public DataAssetInternalCache(AssetCacheType BundleType, string AssetPath) : base(BundleType, AssetPath) { Buffer = null; Asset_ = null; }
public DataAssetBundleCache(AssetCacheType AssetType, string AssetPath, UnityEngine.AssetBundleManifest Manifest) : base(AssetType, AssetPath, Manifest) { AssetList_ = new Dictionary <string, UnityEngine.TextAsset>(); AssetInstanceIDList_ = new List <int>(); }
protected abstract BaseAssetCache CreateAssetCache <T>(AssetCacheType AssetType, string AssetPath) where T : UnityEngine.Object;
public AssetInternalCache(AssetCacheType BundleType, string AssetPath) : base(BundleType, AssetPath) { AssetList_ = new Dictionary <string, T>(); AssetInstanceIDList_ = new List <int>(); }