public static Dictionary <string, FR2_Ref> FindUsageScene(GameObject[] objs, bool depth) { var dict = new Dictionary <string, FR2_Ref>(); // var list = new List<FR2_Ref>(); for (var i = 0; i < objs.Length; i++) { if (FR2_Unity.IsInAsset(objs[i])) { continue; //only get in scene } //add selection if (!dict.ContainsKey(objs[i].GetInstanceID().ToString())) { dict.Add(objs[i].GetInstanceID().ToString(), new FR2_SceneRef(0, objs[i])); } foreach (Object item in FR2_Unity.GetAllRefObjects(objs[i])) { AppendUsageScene(dict, item); } if (depth) { foreach (GameObject child in FR2_Unity.getAllChild(objs[i])) { foreach (Object item2 in FR2_Unity.GetAllRefObjects(child)) { AppendUsageScene(dict, item2); } } } } return(dict); }
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; }