Exemple #1
0
 public static void AddToBlacklist(string path, APAsset asset)
 {
     if (!blacklistStorage.Exists(path))
     {
         blacklistStorage.Add(path);
         SetValue(APAssetType.Blacklist, path, asset);
     }
 }
 public void UpdateObjectsIntoCache(APAssetType type, APAsset asset, Queue <APAsset> modifedAssets = null)
 {
     if (APCache.HasAsset(type, asset.Id))
     {
         APCache.SetValue(type, asset.Id, asset);
         if (modifedAssets != null)
         {
             modifedAssets.Enqueue(asset);
         }
     }
 }
Exemple #3
0
        public static APAsset GetBlackListAPAsset(string path)
        {
            APAsset asset = new APAsset();

            asset.Name   = path;
            asset.Path   = path;
            asset.Icon   = GetIconID(path, path.EndsWith(".ani"));
            asset.APType = AssetType.BLACKLIST;
            asset.Id     = AssetDatabase.AssetPathToGUID(path);

            return(asset);
        }
        public void UpdateObjectsIntoCache(APAssetType type, string assetid, Queue <APAsset> modifedAssets = null)
        {
            APAsset asset = APResources.GetAPAssetByPath(type, assetid);

            if (APCache.HasAsset(type, assetid))
            {
                var previousAssets = APCache.GetValue(type, assetid);
                if (asset != null && previousAssets != null)
                {
                    asset.Used = previousAssets.Used;
                    APCache.SetValue(type, assetid, asset);
                    if (modifedAssets != null)
                    {
                        modifedAssets.Enqueue(asset);
                    }
                }
            }
        }
Exemple #5
0
 public static void SetValue(APAssetType category, string assetid, APAsset value)
 {
     Utility.UpdateJsonInAsset(value);
     if (HasCategory(category))
     {
         if (AssetsCache[(int)category].ContainsKey(assetid))
         {
             AssetsCache[(int)category][assetid] = value;
         }
         else
         {
             AssetsCache[(int)category].Add(assetid, value);
         }
     }
     else
     {
         var assetDict = new Dictionary <string, APAsset>();
         assetDict.Add(assetid, value);
         AssetsCache.Add((int)category, assetDict);
     }
 }
Exemple #6
0
        public static APAsset GetBlackListAPAsset(string path)
        {
            APAsset asset = new APAsset();

            asset.Name = path;
            asset.Path = path;
#if UNITY_2018
            if (path.Equals("Packages/"))
            {
                asset.Icon = GetIconID("Assets");
            }
            else
            {
                asset.Icon = GetIconID(path, path.EndsWith(".ani"));
            }
#else
            asset.Icon = GetIconID(path, path.EndsWith(".ani"));
#endif
            asset.APType = AssetType.BLACKLIST;
            asset.Id     = AssetDatabase.AssetPathToGUID(path);

            return(asset);
        }
Exemple #7
0
 public static void Add(APAssetType category, string assetid, APAsset value)
 {
     Utility.UpdateJsonInAsset(value);
     SetValue(category, assetid, value);
 }
Exemple #8
0
        private static void AddNewImportAssets(string assetPath)
        {
            Utility.DebugLog(string.Format("New: {0}", assetPath));

            if (!File.Exists(assetPath) && Directory.Exists(assetPath))
            {
                return;
            }

            if (Utility.IsStreamingAssetsFile(assetPath))
            {
                APStreamingAssetsFile file = APResources.GetStreamingAssetFile(assetPath);
                APCache.Add(APAssetType.StreamingAssets, file.Id, file);
                SyncManager.AddedAssets.Enqueue(file);
                return;
            }
            else if (Utility.IsCodeFile(assetPath))
            {
                APCodeFile codeFile = APResources.GetCodeFile(assetPath);
                APCache.Add(APAssetType.Script, codeFile.Id, codeFile);
                SyncManager.AddedAssets.Enqueue(codeFile);
                return;
            }

            var guid = AssetDatabase.AssetPathToGUID(assetPath);

            UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(assetPath, typeof(UnityEngine.Object));

            APAsset asset = null;

            // if new path
            //
            if (obj is Texture)
            {
                if (obj is MovieTextureType)
                {
                    var movie = APResources.GetAPAssetByPath(APAssetType.MovieTexture, guid);
                    if (movie != null)
                    {
                        APCache.SetValue(APAssetType.MovieTexture, movie.Id, movie);
                    }
                    SyncManager.AddedAssets.Enqueue(movie);
                    return;
                }

                asset = APResources.GetAPAssetByPath(APAssetType.Texture, guid);
                if (asset != null)
                {
                    APCache.SetValue(APAssetType.Texture, asset.Id, asset);
                }
            }
            else if (Utility.IsModels(obj, assetPath))
            {
                AddModelInCache(assetPath);
                return;
            }
            else if (obj is AnimationClip)
            {
                asset = APResources.GetAPAssetByPath(APAssetType.AnimationClip, guid);
                if (asset != null)
                {
                    APCache.SetValue(APAssetType.AnimationClip, asset.Id, asset);
                }
            }
            else if (obj is AudioClip)
            {
                asset = APResources.GetAPAssetByPath(APAssetType.AudioClip, guid);
                if (asset != null)
                {
                    APCache.SetValue(APAssetType.AudioClip, asset.Id, asset);
                }
            }
            else if (obj is Font)
            {
                asset = APResources.GetAPAssetByPath(APAssetType.Font, guid);
                if (asset != null)
                {
                    APCache.SetValue(APAssetType.Font, asset.Id, asset);
                }
            }
            else if (obj is Shader)
            {
                asset = APResources.GetAPAssetByPath(APAssetType.Shader, guid);
                if (asset != null)
                {
                    APCache.SetValue(APAssetType.Shader, asset.Id, asset);
                }
            }
            else if (obj is Material || obj is PhysicMaterial || obj is PhysicsMaterial2D)
            {
                asset = APResources.GetAPAssetByPath(APAssetType.Material, guid);
                if (asset != null)
                {
                    APCache.SetValue(APAssetType.Material, asset.Id, asset);
                }
            }
            else if (Utility.IsPrefab(assetPath))
            {
                asset = APResources.GetAPAssetByPath(APAssetType.Prefab, guid);
                if (asset != null)
                {
                    APCache.SetValue(APAssetType.Prefab, asset.Id, asset);
                }
            }
            else
            {
                if (assetPath.ToLower().StartsWith("assets"))
                {
                    asset = APResources.GetOtherFile(assetPath);
                    if (asset != null)
                    {
                        APCache.Add(APAssetType.Others, asset.Id, asset);
                    }
                }
            }

            if (asset != null)
            {
                SyncManager.AddedAssets.Enqueue(asset);
            }

            Utility.DebugLog("New object type = " + obj);
        }
        public static void UpdateJsonInAsset(APAsset asset)
        {
            string json = APJsonSerializer.ToJson(asset);

            asset.Json = SafeJson(json);
        }