Exemple #1
0
        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);
            }
        }
Exemple #2
0
 protected BaseAssetBundleCache(AssetCacheType AssetType, string AssetPath, UnityEngine.AssetBundleManifest Manifest)
     : base(AssetType, AssetPath)
 {
     this.Manifest_ = Manifest;
     this.Request_  = null;
     this.Bundle_   = null;
 }
Exemple #3
0
        protected BaseAssetCache(AssetCacheType AssetType, string AssetPath)
        {
            this.AssetType = AssetType;
            this.AssetPath = AssetPath;

            this.IsLoad             = false;
            this.RefCount_          = 0;
            this.DependenciesCache_ = new List <BaseAssetCache>();
        }
Exemple #4
0
        protected override BaseAssetCache LoadAssetSync <T>(AssetCacheType AssetType, string AssetPath)
        {
            AssetPath = AssetPath.ToLower();
            if (!AssetBundlePathList_.Contains(AssetPath))
            {
                return(null);
            }

            return(base.LoadAssetSync <T>(AssetType, AssetPath));
        }
Exemple #5
0
        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));
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        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);
    }
Exemple #9
0
        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)
                };
            }
        }
Exemple #10
0
        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);
            }
        }
Exemple #11
0
        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); });
            });
        }
Exemple #12
0
        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);
        }
Exemple #13
0
 protected BaseAssetInternalCache(AssetCacheType AssetType, string AssetPath)
     : base(AssetType, AssetPath)
 {
     this.Bundle = null;
 }
Exemple #14
0
 public PrefabAssetInternalCache(AssetCacheType BundleType, string AssetPath)
     : base(BundleType, AssetPath)
 {
     AssetList_           = new Dictionary <string, UnityEngine.GameObject>();
     AssetInstanceIDList_ = new List <int>();
 }
Exemple #15
0
 public DataAssetInternalCache(AssetCacheType BundleType, string AssetPath)
     : base(BundleType, AssetPath)
 {
     Buffer = null;
     Asset_ = null;
 }
Exemple #16
0
 public DataAssetBundleCache(AssetCacheType AssetType, string AssetPath, UnityEngine.AssetBundleManifest Manifest)
     : base(AssetType, AssetPath, Manifest)
 {
     AssetList_           = new Dictionary <string, UnityEngine.TextAsset>();
     AssetInstanceIDList_ = new List <int>();
 }
Exemple #17
0
 protected abstract BaseAssetCache CreateAssetCache <T>(AssetCacheType AssetType, string AssetPath) where T : UnityEngine.Object;
Exemple #18
0
 public AssetInternalCache(AssetCacheType BundleType, string AssetPath)
     : base(BundleType, AssetPath)
 {
     AssetList_           = new Dictionary <string, T>();
     AssetInstanceIDList_ = new List <int>();
 }