Пример #1
0
 private void CopyIsExpanded(HashSet <HierarchyEntry> src,
                             HashSet <HierarchyEntry> dest)
 {
     foreach (var entry in src)
     {
         HierarchyEntry newEntry = null;
         if ((newEntry = dest.FirstOrDefault(e => e.Transform == entry.Transform))
             != null)
         {
             newEntry.IsExpanded = entry.IsExpanded;
             CopyIsExpanded(entry.Children, newEntry.Children);
         }
     }
 }
Пример #2
0
        private HashSet <HierarchyEntry> Flatten(HierarchyEntry root)
        {
            var flattened = new HashSet <HierarchyEntry>()
            {
                root
            };
            var children = root.Children;

            if (children != null)
            {
                foreach (var child in children)
                {
                    flattened.UnionWith(Flatten(child));
                }
            }
            return(flattened);
        }
Пример #3
0
        public void RefreshGameObjectList()
        {
            var newEntries = new HashSet <HierarchyEntry>();

            foreach (var transform in FindObjectsOfType <Transform>())
            {
                if (transform.parent == null)
                {
                    var entry = new HierarchyEntry(transform);
                    newEntries.Add(entry);
                }
            }
            CopyIsExpanded(inspectorEntries, newEntries);
            inspectorEntries = newEntries;
            if (isSearching)
            {
                RefreshSearchList();
            }
        }
Пример #4
0
        private bool EntryOrChildrenContain(HierarchyEntry entry, string text)
        {
            string toSearch = text.ToLower();

            if (entry.Transform == null)
            {
                return(false);
            }
            if (entry.Transform.name.ToLower().Contains(toSearch))
            {
                return(true);
            }
            foreach (var child in entry.Children)
            {
                if (EntryOrChildrenContain(child, text))
                {
                    return(true);
                }
            }
            return(false);
        }