Example #1
0
        private void LoadAssetCacheDependenciesAsync <T>(BaseAssetCache Cache, Action <bool> Callback = null) where T : UnityEngine.Object
        {
            var LoadCompletedCount = 0;
            var Dependencies       = Cache.GetAllDependencies();

            if (Dependencies == null || Dependencies.Length == 0)
            {
                Callback?.Invoke(true);
                return;
            }

            foreach (var Dependency in Dependencies)
            {
                var AssetPath = Dependency;
                var AssetType = GetAssetTypeWithName <T>(AssetPath);
                LoadAssetAsync <T>(AssetType, AssetPath, (IsLoaded) =>
                {
                    if (!IsLoaded)
                    {
                        Callback?.Invoke(false);
                        return;
                    }

                    Cache.AddDependencyCache(AssetCacheList_[AssetPath]);
                    LoadCompletedCount++;

                    if (LoadCompletedCount >= Dependencies.Length)
                    {
                        Callback?.Invoke(true);
                    }
                });
            }
        }
Example #2
0
        private void LoadAssetCacheDependenciesSync <T>(BaseAssetCache Cache) where T : UnityEngine.Object
        {
            var Dependencies = Cache.GetAllDependencies();

            if (Dependencies == null || Dependencies.Length == 0)
            {
                return;
            }

            foreach (var Dependency in Dependencies)
            {
                var AssetPath = Dependency;
                var AssetType = GetAssetTypeWithName <T>(AssetPath);

                var DependencyAsset = LoadAssetSync <T>(AssetType, AssetPath);
                if (DependencyAsset != null)
                {
                    Cache.AddDependencyCache(DependencyAsset);
                }
            }
        }