private static void ApplyFilter(Dictionary <string, FR2_Ref> refs, FR2_Asset asset) { string targetPath = AssetDatabase.GUIDToAssetPath(asset.guid); if (string.IsNullOrEmpty(targetPath)) { return; // asset not found - might be deleted! } //asset being moved! if (targetPath != asset.assetPath) { asset.LoadAssetInfo(); } Object target = AssetDatabase.LoadAssetAtPath(targetPath, typeof(Object)); if (target == null) { Debug.LogWarning("target is null"); return; } bool targetIsGameobject = target is GameObject; if (targetIsGameobject) { foreach (GameObject item in FR2_Unity.getAllObjsInCurScene()) { if (FR2_Unity.CheckIsPrefab(item)) { string itemGUID = FR2_Unity.GetPrefabParent(item); // Debug.Log(item.name + " itemGUID: " + itemGUID); // Debug.Log(target.name + " asset.guid: " + asset.guid); if (itemGUID == asset.guid) { Add(refs, item, 1); } } } } string dir = Path.GetDirectoryName(targetPath); if (FR2_SceneCache.Api.folderCache.ContainsKey(dir)) { foreach (Component item in FR2_SceneCache.Api.folderCache[dir]) { if (FR2_SceneCache.Api.cache.ContainsKey(item)) { foreach (FR2_SceneCache.HashValue item1 in FR2_SceneCache.Api.cache[item]) { if (targetPath == AssetDatabase.GetAssetPath(item1.target)) { Add(refs, item, 1); } } } } } }
public void refreshCache(IWindow window) { if (window == null) { return; } // if(!ready) return; this.window = window; _cache = new Dictionary <Component, HashSet <HashValue> >(); folderCache = new Dictionary <string, HashSet <Component> >(); prefabDependencies = new Dictionary <GameObject, HashSet <string> >(); ready = false; List <GameObject> listRootGO = null; #if SUPPORT_NESTED_PREFAB if (PrefabStageUtility.GetCurrentPrefabStage() != null) { GameObject rootPrefab = PrefabStageUtility.GetCurrentPrefabStage().prefabContentsRoot; if (rootPrefab != null) { listRootGO = new List <GameObject> { rootPrefab }; } } #else #endif if (listRootGO == null) { listGO = FR2_Unity.getAllObjsInCurScene().ToList(); } else { listGO = new List <GameObject>(); foreach (GameObject item in listRootGO) { listGO.AddRange(FR2_Unity.getAllChild(item, true)); } } total = listGO.Count; current = 0; // Debug.Log("refresh cache total " + total); EditorApplication.update -= OnUpdate; EditorApplication.update += OnUpdate; // foreach (var item in FR2_Helper.getAllObjsInCurScene()) // { // // Debug.Log("object in scene: " + item.name); // Component[] components = item.GetComponents<Component>(); // foreach (var com in components) // { // if(com == null) continue; // SerializedObject serialized = new SerializedObject(com); // SerializedProperty it = serialized.GetIterator().Copy(); // while (it.NextVisible(true)) // { // if (it.propertyType != SerializedPropertyType.ObjectReference) continue; // if (it.objectReferenceValue == null) continue; // if(!_cache.ContainsKey(com)) _cache.Add(com, new HashSet<SerializedProperty>()); // if(!_cache[com].Contains(it)) // _cache[com].Add(it.Copy()); // } // } // } Dirty = false; }