Exemplo n.º 1
0
        private static void LoadResourcesIntoCache(APAssetType type)
        {
            IList assets = null;
            Dictionary <string, APAsset> dict = new Dictionary <string, APAsset>();

            switch (type)
            {
            case APAssetType.Font:
                assets = APResources.GetFonts();
                break;

            case APAssetType.MovieTexture:
                assets = APResources.GetMovies();
                break;

            case APAssetType.Texture:
                assets = APResources.GetTextures();
                break;

            case APAssetType.Model:
                assets = APResources.GetModels();
                break;

            case APAssetType.AudioClip:
                assets = APResources.GetAudios();
                break;

            case APAssetType.Material:
                assets = APResources.GetMaterials();
                break;

            case APAssetType.Shader:
                assets = APResources.GetShaders();
                break;

            case APAssetType.AnimationClip:
                assets = APResources.GetAnimations();
                break;

            case APAssetType.Prefab:
                assets = APResources.GetPrefabs();
                break;

            case APAssetType.StreamingAssets:
                assets = APResources.GetStreamingAssets();
                break;

            case APAssetType.Script:
                assets = APResources.GetCodeFiles();
                break;

            case APAssetType.Blacklist:
                assets = blacklistStorage.GetAssets();
                break;

            case APAssetType.Others:
                assets = APResources.GetOthers();
                break;
            }

            if (assets == null)
            {
                return;
            }

            foreach (var item in assets)
            {
                var asset = item as APAsset;
                if (asset == null)
                {
                    break;
                }

                Utility.UpdateJsonInAsset(asset);

                if (!dict.ContainsKey(asset.Id))
                {
                    dict.Add(asset.Id, asset);
                }
                else
                {
                    dict[asset.Id] = asset;
                }
            }

            int key = (int)type;

            if (AssetsCache.ContainsKey(key))
            {
                AssetsCache[key] = dict;
            }
            else
            {
                AssetsCache.Add(key, dict);
            }
        }