void DoObjectSearchInChild(Transform[] objects, string filter) { var props = new HierarchyProperty(HierarchyType.GameObjects); props.SetSearchFilter(filter, 0); props.Reset(); while (props.Next(null)) { if (res.Count >= kMaxLists) { return; } var obj = ((GameObject)EditorUtility.InstanceIDToObject(props.instanceID)); if (!obj || (objects.Length > 0 && !objects.Any(x => x && obj.transform.IsChildOf(x)))) { continue; } res.Add(new ID() { name = props.name, gui = new GUIContent(props.name, AssetPreview.GetMiniThumbnail(props.pptrValue)), obj = props.instanceID }); } }
void DoComponentSearch(string filter) { InitTypeIndexing(); var types = components.Where((x) => StringContains(x.name, filter)); var props = new HierarchyProperty(HierarchyType.GameObjects); foreach (var type in types) { props.SetSearchFilter("t:" + type.name, 0); props.Reset(); while (props.Next(null)) { if (res.Count >= kMaxLists) { return; } if (!res.Any((x) => props.instanceID == (int)x.obj)) { res.Add(new ID() { name = props.name, gui = new GUIContent(props.name, AssetPreview.GetMiniThumbnail( (props.pptrValue as GameObject).GetComponent(type.type))), obj = props.instanceID }); } } } }
void DoObjectSubstractiveSearch(string filter) { var sel = Selection.instanceIDs; if (sel.Length == 0) { return; } var props = new HierarchyProperty(HierarchyType.GameObjects); props.SetSearchFilter(filter, 0); props.Reset(); while (props.Next(null)) { if (res.Count >= kMaxLists) { return; } if (sel.Contains(props.instanceID)) { res.Add(new ID() { name = props.name, gui = new GUIContent(props.name, AssetPreview.GetMiniThumbnail(props.pptrValue)), obj = props.instanceID }); } } }
void UpdateHierarchyData() { if (m_HierarchyProperty == null) { m_HierarchyProperty = new HierarchyProperty(HierarchyType.GameObjects); m_HierarchyProperty.Next(null); } else { m_HierarchyProperty.Reset(); m_HierarchyProperty.Next(null); } bool hasChanged = false; var hasNext = true; m_HierarchyData = CollectHierarchyData(ref hasNext, ref hasChanged, m_HierarchyData, m_HierarchyProperty); if (hasChanged) { foreach (var list in m_HierarchyLists) { list.hierarchyData = GetHierarchyData(); } } }
void UpdateHierarchyData() { m_ObjectTypes.Clear(); if (m_HierarchyProperty == null) { m_HierarchyProperty = new HierarchyProperty(HierarchyType.GameObjects); m_HierarchyProperty.Next(null); } else { m_HierarchyProperty.Reset(); m_HierarchyProperty.Next(null); } var hasChanged = false; var hasNext = true; m_HierarchyData = CollectHierarchyData(ref hasNext, ref hasChanged, m_HierarchyData, m_HierarchyProperty, m_ObjectTypes); if (hasChanged) { foreach (var list in m_HierarchyLists) { list.hierarchyData = GetHierarchyData(); } // Send new data to existing filterUIs foreach (var filterUI in m_FilterUIs) { filterUI.filterList = GetFilterList(); } } }
public static List <string> FindAllTextAssets() { var hierarchyProperty = new HierarchyProperty(HierarchyType.Assets); hierarchyProperty.SetSearchFilter("t:TextAsset", 0); hierarchyProperty.Reset(); List <string> list = new List <string>(); while (hierarchyProperty.Next(null)) { list.Add(hierarchyProperty.guid); } return(list); }
private void SearchAllAssets(string filter) { var assembly = typeof(EditorWindow).Assembly; var searchFilter = assembly.CreateInstance("UnityEditor.SearchFilter"); ParseSearchString(filter, searchFilter); var property = new HierarchyProperty(HierarchyType.Assets); SetSearchFilter(property, searchFilter); property.Reset(); searchBuf.Clear(); while (property.Next(null)) { searchBuf.Add(new SearchBuf { name = property.name, instanceID = property.instanceID }); } }
void DoSceneSearch(string filter) { var props = new HierarchyProperty(HierarchyType.Assets); props.SetSearchFilter(filter + " t:Scene", 0); props.Reset(); while (props.Next(null)) { if (res.Count >= kMaxLists) { return; } res.Add(new ID() { name = AssetDatabase.GUIDToAssetPath(props.guid), gui = new GUIContent(props.name, AssetPreview.GetMiniThumbnail(props.pptrValue)), obj = props.instanceID }); } }
void UpdateHierarchyData() { m_ObjectTypes.Clear(); if (m_HierarchyProperty == null) { m_HierarchyProperty = new HierarchyProperty(HierarchyType.GameObjects); } else { m_HierarchyProperty.Reset(); } var hasChanged = false; var lastDepth = 0; m_DataStack.Clear(); m_SiblingIndexStack.Clear(); m_DataStack.Push(null); m_SiblingIndexStack.Push(0); while (m_HierarchyProperty.Next(null)) { var instanceID = m_HierarchyProperty.instanceID; var go = EditorUtility.InstanceIDToObject(instanceID) as GameObject; var currentDepth = m_HierarchyProperty.depth; if (m_IgnoreList.Contains(go)) { var depth = currentDepth; // skip children of EVR to prevent the display of EVR contents while (m_HierarchyProperty.Next(null) && m_HierarchyProperty.depth > depth) { } currentDepth = m_HierarchyProperty.depth; instanceID = m_HierarchyProperty.instanceID; // If EVR is the last object, early out if (instanceID == 0) { break; } continue; } if (currentDepth <= lastDepth) { if (m_DataStack.Count > 1) // Pop off last sibling { if (CleanUpHierarchyData(m_DataStack.Pop(), m_SiblingIndexStack.Pop())) { hasChanged = true; } } var count = lastDepth - currentDepth; while (count-- > 0) { if (CleanUpHierarchyData(m_DataStack.Pop(), m_SiblingIndexStack.Pop())) { hasChanged = true; } } } var parent = m_DataStack.Peek(); var siblingIndex = m_SiblingIndexStack.Pop(); if (parent != null && parent.children == null) { parent.children = new List <HierarchyData>(); } var children = parent == null ? m_HierarchyData : parent.children; HierarchyData currentHierarchyData; if (siblingIndex >= children.Count) { currentHierarchyData = new HierarchyData(m_HierarchyProperty); var types = new HashSet <string>(); InstanceIDToComponentTypes(instanceID, types, m_ObjectTypes); currentHierarchyData.types = types; children.Add(currentHierarchyData); hasChanged = true; } else if (children[siblingIndex].index != instanceID) { currentHierarchyData = new HierarchyData(m_HierarchyProperty); var types = new HashSet <string>(); InstanceIDToComponentTypes(instanceID, types, m_ObjectTypes); currentHierarchyData.types = types; children[siblingIndex] = currentHierarchyData; hasChanged = true; } else { currentHierarchyData = children[siblingIndex]; InstanceIDToComponentTypes(instanceID, currentHierarchyData.types, m_ObjectTypes); } m_DataStack.Push(currentHierarchyData); m_SiblingIndexStack.Push(siblingIndex + 1); m_SiblingIndexStack.Push(0); lastDepth = currentDepth; } while (m_SiblingIndexStack.Count > 0 && m_DataStack.Count > 0) { if (CleanUpHierarchyData(m_DataStack.Pop(), m_SiblingIndexStack.Pop())) { hasChanged = true; } } if (hasChanged) { foreach (var list in m_HierarchyLists) { list.hierarchyData = GetHierarchyData(); } // Send new data to existing filterUIs foreach (var filterUI in m_FilterUIs) { filterUI.filterList = GetFilterList(); } } }