Пример #1
0
        static void SearchProcess(Func <GameObject, bool> e)
        {
            var list               = new List <object>();
            var items              = SceneHierarchyWindowHelper.GetRows().GetEnumerator();
            var itemType           = items.GetType().GetGenericArguments()[0];
            var itemIdPropertyInfo = itemType.GetProperty("id", BindingFlags.Public | BindingFlags.Instance);
            var activeId           = Selection.activeInstanceID;

            while (items.MoveNext())
            {
                var id = (int)itemIdPropertyInfo.GetValue(items.Current, null);
                Selection.activeInstanceID = id;
                if (e(Selection.activeGameObject))
                {
                    list.Add(items.Current);
                }
            }
            Selection.activeInstanceID = activeId;
            var itemList = Activator.CreateInstance(typeof(List <>).MakeGenericType(new Type[] {
                itemType,
            }));
            var addMethod = itemList.GetType().GetMethod("Add");

            for (int i = 0; i < list.Count; i++)
            {
                addMethod.Invoke(itemList, new object[] {
                    list [i],
                });
            }
            SceneHierarchyWindowHelper.SetRows(itemList);
            SceneHierarchyWindowHelper.SetRowCount(list.Count);
        }
Пример #2
0
 public static void SearchForAllMissingComponents()
 {
     SceneHierarchyWindowHelper.Show();
     SceneHierarchyWindowHelper.SetRows(null);
     SceneHierarchyWindowHelper.ReloadData();
     SceneHierarchyWindowHelper.SearchFilter = "t: Component";
     SceneHierarchyWindowHelper.SearchChanged();
     SearchProcess(go =>
     {
         return(HaveMissingComponent(go));
     });
     SceneHierarchyWindowHelper.Repaint();
 }