Explorar o código

SceneEditor: add undo / redo on set visible

lviguier hai 3 meses
pai
achega
df6e62710e
Modificáronse 1 ficheiros con 17 adicións e 12 borrados
  1. 17 12
      hide/comp/SceneEditor.hx

+ 17 - 12
hide/comp/SceneEditor.hx

@@ -4475,22 +4475,27 @@ class SceneEditor {
 		if (tree == null)
 		if (tree == null)
 			tree = this.tree;
 			tree = this.tree;
 
 
-		for(o in elements) {
-			for(c in o.flatten(Object3D)) {
-				if( visible )
-					hideList.remove(c);
-				else
-					hideList.set(o, true);
-				var el = tree.getElement(c);
-				if( el != null ) applyTreeStyle(c, el, tree);
-				applySceneStyle(c);
+		function exec(undo : Bool) {
+			for(o in elements) {
+				for(c in o.flatten(Object3D)) {
+					if( visible )
+						undo ? hideList.set(o, true) : hideList.remove(c);
+					else
+						undo ?  hideList.remove(c) : hideList.set(o, true);
+					var el = tree.getElement(c);
+					if( el != null ) applyTreeStyle(c, el, tree);
+					applySceneStyle(c);
 
 
-				if (Std.downcast(c, hrt.prefab.RenderProps) != null) {
-					queueRefreshRenderProps();
+					if (Std.downcast(c, hrt.prefab.RenderProps) != null) {
+						queueRefreshRenderProps();
+					}
 				}
 				}
 			}
 			}
+			saveDisplayState();
 		}
 		}
-		saveDisplayState();
+
+		exec(false);
+		undo.change(Custom(exec), null, true);
 	}
 	}
 
 
 	public function setLock(elements : Array<PrefabElement>, locked: Bool, enableUndo : Bool = true, ?tree: IconTree<PrefabElement>) {
 	public function setLock(elements : Array<PrefabElement>, locked: Bool, enableUndo : Bool = true, ?tree: IconTree<PrefabElement>) {