Beispiel #1
0
        internal void ReadFromProject(bool force)
        {
            var paths = AssetDatabase.GetAllAssetPaths().ToList();

            paths.RemoveAll(item => !item.StartsWith("Assets/"));
            var guids = paths.Select(item => AssetDatabase.AssetPathToGUID(item)).ToArray();

            cacheStamp++;

            // Check for new assets
            for (var i = 0; i < guids.Length; i++)
            {
                if (!FR2_Asset.IsValidGUID(guids[i]))
                {
                    continue;
                }

                FR2_Asset asset;

                if (AssetMap.TryGetValue(guids[i], out asset))
                {
                    asset.cacheStamp = cacheStamp;
                    continue;
                }

                ;

                // New asset
                AddAsset(guids[i]);
            }

            // Check for deleted assets
            for (var i = AssetList.Count - 1; i >= 0; i--)
            {
                if (AssetList[i].cacheStamp != cacheStamp)
                {
                    RemoveAsset(AssetList[i]);
                }
            }

            // Refresh definition list
            for (var i = 0; i < AssetList.Count; i++)
            {
                AddSymbols(AssetList[i]);
            }

            if (force)
            {
                timeStamp  = FR2_Unity.Epoch(DateTime.Now);
                workCount += AssetMap.Count;
                queueLoadContent.AddRange(AssetMap.Values.ToList());
            }
        }
Beispiel #2
0
        private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets,
                                                   string[] movedFromAssetPaths)
        {
            if (EditorApplication.isUpdating || EditorApplication.isPlaying)
            {
                return;
            }
            //Debug.Log("OnPostProcessAllAssets : "+ FR2_Cache.Api.isReady + ":" + importedAssets.Length + ":" + deletedAssets.Length + ":" + movedAssets.Length + ":" + movedFromAssetPaths.Length);

            if (!FR2_Cache.isReady)
            {
#if FR2_DEBUG
                Debug.Log("Not ready, will refresh anyway !");
#endif
                return;
            }

            for (var i = 0; i < importedAssets.Length; i++)
            {
                if (importedAssets[i] == FR2_Cache.CachePath)
                {
                    continue;
                }

                var guid = AssetDatabase.AssetPathToGUID(importedAssets[i]);
                if (!FR2_Asset.IsValidGUID(guid))
                {
                    continue;
                }
                if (FR2_Cache.Api.AssetMap.ContainsKey(guid))
                {
                    FR2_Cache.Api.RefreshAsset(guid, false);

#if FR2_DEBUG
                    Debug.Log("Changed : " + importedAssets[i]);
#endif

                    continue;
                }

                FR2_Cache.Api.AddAsset(guid);
#if FR2_DEBUG
                Debug.Log("New : " + importedAssets[i]);
#endif
            }

            for (var i = 0; i < deletedAssets.Length; i++)
            {
                var guid = AssetDatabase.AssetPathToGUID(deletedAssets[i]);
                FR2_Cache.Api.RemoveAsset(guid);

#if FR2_DEBUG
                Debug.Log("Deleted : " + deletedAssets[i]);
#endif
            }

            for (var i = 0; i < movedAssets.Length; i++)
            {
                var guid  = AssetDatabase.AssetPathToGUID(movedAssets[i]);
                var asset = FR2_Cache.Api.Get(guid);
                if (asset != null)
                {
                    asset.LoadAssetInfo();
                }
            }

#if FR2_DEBUG
            Debug.Log("Changes :: " + importedAssets.Length + ":" + FR2_Cache.Api.workCount);
#endif

            if (FR2_Cache.Api.workCount > 0)
            {
                FR2_Cache.Api.Check4Usage();
            }
        }