瀏覽代碼

Add feature that allow to enable all hidden before nodes on one hotkey

MonkeyFirst 10 年之前
父節點
當前提交
1f519959aa
共有 2 個文件被更改,包括 63 次插入3 次删除
  1. 54 0
      bin/Data/Scripts/Editor/EditorScene.as
  2. 9 3
      bin/Data/Scripts/Editor/EditorUI.as

+ 54 - 0
bin/Data/Scripts/Editor/EditorScene.as

@@ -861,6 +861,60 @@ bool SceneToggleEnable()
     return true;
     return true;
 }
 }
 
 
+bool SceneEnableAllNodes()
+{
+    if (!CheckHierarchyWindowFocus())
+        return false;
+
+    ui.cursor.shape = CS_BUSY;
+
+    EditActionGroup group;
+
+    // Toggle enabled state of nodes recursively
+    Array<Node@> allNodes;
+    allNodes = editorScene.GetChildren(true);
+    
+    for (uint i = 0; i < allNodes.length; ++i)
+    {
+        // Do not attempt to disable the Scene
+        if (allNodes[i].typeName == "Node")
+        {
+            bool oldEnabled = allNodes[i].enabled;
+            if (oldEnabled == false)
+              allNodes[i].SetEnabledRecursive(true);
+
+            // Create undo action
+            ToggleNodeEnabledAction action;
+            action.Define(allNodes[i], oldEnabled);
+            group.actions.Push(action);
+        }
+    }
+    
+    Array<Component@> allComponents;
+    allComponents = editorScene.GetComponents();
+    
+    for (uint i = 0; i < allComponents.length; ++i)
+    {
+        // Some components purposefully do not expose the Enabled attribute, and it does not affect them in any way
+        // (Octree, PhysicsWorld). Check that the first attribute is in fact called "Is Enabled"
+        if (allComponents[i].numAttributes > 0 && allComponents[i].attributeInfos[0].name == "Is Enabled")
+        {
+            bool oldEnabled = allComponents[i].enabled;
+            allComponents[i].enabled = true;
+
+            // Create undo action
+            EditAttributeAction action;
+            action.Define(allComponents[i], 0, Variant(oldEnabled));
+            group.actions.Push(action);
+        }
+    }
+
+    SaveEditActionGroup(group);
+    SetSceneModified();
+
+    return true;
+}
+
 bool SceneChangeParent(Node@ sourceNode, Node@ targetNode, bool createUndoAction = true)
 bool SceneChangeParent(Node@ sourceNode, Node@ targetNode, bool createUndoAction = true)
 {
 {
     // Create undo action if requested
     // Create undo action if requested

+ 9 - 3
bin/Data/Scripts/Editor/EditorUI.as

@@ -357,11 +357,17 @@ void CreateMenuBar()
             popup.AddChild(CreateMenuItem("Reset scale", @SceneResetScale, 'S', QUAL_ALT));
             popup.AddChild(CreateMenuItem("Reset scale", @SceneResetScale, 'S', QUAL_ALT));
         }
         }
         
         
-        if ( hotKeyMode == HOT_KEYS_MODE_STANDART )    
+        if ( hotKeyMode == HOT_KEYS_MODE_STANDART ) 
+        {
             popup.AddChild(CreateMenuItem("Enable/disable", @SceneToggleEnable, 'E', QUAL_CTRL));
             popup.AddChild(CreateMenuItem("Enable/disable", @SceneToggleEnable, 'E', QUAL_CTRL));
-        else if ( hotKeyMode == HOT_KEYS_MODE_BLENDER )
+            popup.AddChild(CreateMenuItem("Enable all", @SceneEnableAllNodes, 'E', QUAL_ALT));
+        }
+        else if ( hotKeyMode == HOT_KEYS_MODE_BLENDER ) 
+        {
             popup.AddChild(CreateMenuItem("Enable/disable", @SceneToggleEnable, 'H'));
             popup.AddChild(CreateMenuItem("Enable/disable", @SceneToggleEnable, 'H'));
-
+            popup.AddChild(CreateMenuItem("Enable all", @SceneEnableAllNodes, 'H', QUAL_ALT));
+        }
+        
         if ( hotKeyMode == HOT_KEYS_MODE_STANDART )
         if ( hotKeyMode == HOT_KEYS_MODE_STANDART )
             popup.AddChild(CreateMenuItem("Unparent", @SceneUnparent, 'U', QUAL_CTRL));
             popup.AddChild(CreateMenuItem("Unparent", @SceneUnparent, 'U', QUAL_CTRL));
         else if ( hotKeyMode == HOT_KEYS_MODE_BLENDER )
         else if ( hotKeyMode == HOT_KEYS_MODE_BLENDER )