示例#1
0
    private static void SetFoldValueForAllGameObjectsInHiearchy(FoldValue fv) {
      var toplevelGos = Object.FindObjectsOfType<GameObject>().Where(g => g.transform.parent == null);

      foreach (GameObject g in toplevelGos) {
        HierarchyUtil.SetFoldValueForGameObjectInHiearchyRecursive(g, fv);
      }
    }
        private static void SetFoldValueForAllGameObjectsInHiearchy(FoldValue fv)
        {
            var toplevelGos = Object.FindObjectsOfType <GameObject>().Where(g => g.transform.parent == null);

            foreach (GameObject g in toplevelGos)
            {
                SetFoldValueForGameObjectInHiearchyRecursive(g, fv);
            }
        }
        public static bool BoolValue(this FoldValue fv)
        {
            switch (fv)
            {
            case FoldValue.EXPANDED:
                return(true);

            case FoldValue.COLLAPSED:
            default:
                return(false);
            }
        }
示例#4
0
    private static void SetFoldValueForGameObjectInHiearchyRecursive(GameObject gameObject, FoldValue fv) {
      var type = typeof(EditorWindow).Assembly.GetType("UnityEditor.SceneHierarchyWindow");
      var methodInfo = type.GetMethod("SetExpandedRecursive");

      EditorApplication.ExecuteMenuItem("Window/Hierarchy");
      EditorWindow window = EditorWindow.focusedWindow;

      methodInfo.Invoke(window, new object[] {
        gameObject.GetInstanceID(),
        fv.BoolValue()
      });
    }
        private static void SetFoldValueForGameObjectInHiearchyRecursive(GameObject gameObject, FoldValue fv)
        {
            var type       = typeof(EditorWindow).Assembly.GetType("UnityEditor.SceneHierarchyWindow");
            var methodInfo = type.GetMethod("SetExpandedRecursive");

            EditorApplication.ExecuteMenuItem("Window/Hierarchy");
            EditorWindow window = EditorWindow.focusedWindow;

            methodInfo.Invoke(window, new object[] {
                gameObject.GetInstanceID(),
                fv.BoolValue()
            });
        }