Ejemplo n.º 1
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void AddNewImportAssets(string assetPath)
        {
            Utility.DebugLog(string.Format("New: {0}", assetPath));

            if (!File.Exists(assetPath) && Directory.Exists(assetPath))
            {
                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 MovieTexture)
                {
                    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);
                }
            }

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

            Resources.UnloadUnusedAssets();
        }
Ejemplo n.º 3
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);
     }
 }
Ejemplo n.º 4
0
 public static void Add(APAssetType category, string assetid, APAsset value)
 {
     Utility.UpdateJsonInAsset(value);
     SetValue(category, assetid, value);
 }
Ejemplo n.º 5
0
        public static void UpdateJsonInAsset(APAsset asset)
        {
            string json = APJsonSerializer.ToJson(asset);

            asset.Json = SafeJson(json);
        }