private static void OnGameObjectComponentTraverse(ObjectTraverseInfo traverseInfo, Component component, int orderIndex) { if (component == null) return; var target = traverseInfo.current; var componentName = CSComponentTools.GetComponentName(component); if (CSObjectTools.IsHiddenInInspector(component)) { orderIndex = -1; } var addSettings = new EntryAddSettings { componentName = componentName, componentIndex = orderIndex, componentInstanceId = component.GetInstanceID(), }; TraverseObjectProperties(target, component, addSettings); }
public static HierarchyReferenceItem[] FindObjectsReferencesInHierarchy(Object[] objects, bool checkGameObjectsComponents, bool showResults = true) { if (UserSettings.References.clearHierarchyResults) { SearchResultsStorage.HierarchyReferencesLastSearched = new int[0]; SearchResultsStorage.HierarchyReferencesSearchResults = new HierarchyReferenceItem[0]; } var lastSearched = SearchResultsStorage.HierarchyReferencesLastSearched; var allObjects = CSObjectTools.GetObjectsFromInstanceIds(lastSearched); var items = new List <Object>(objects); if (checkGameObjectsComponents) { for (var i = items.Count - 1; i >= 0; i--) { var item = items[i]; var gameObject = item as GameObject; if (gameObject == null) { continue; } var components = gameObject.GetComponents <Component>(); foreach (var component in components) { if (component == null) { continue; } if (CSObjectTools.IsHiddenInInspector(component)) { continue; } items.Insert(i, component); } } } var newItem = false; foreach (var o in items) { if (!ArrayUtility.Contains(allObjects, o)) { newItem = true; ArrayUtility.Add(ref allObjects, o); } } if (items.Count == 1) { HierarchyReferencesTab.AutoSelectHierarchyReference = ObjectToReferencingEntry(items[0]).reference; } HierarchyReferenceItem[] result; if (newItem) { result = FindHierarchyObjectsReferences(allObjects, items.ToArray(), showResults); } else { MaintainerWindow.ShowObjectReferences(); result = SearchResultsStorage.HierarchyReferencesSearchResults; } return(result); }