Browse Source

Toolbar: allow hiding object3D UI

lviguier 1 year ago
parent
commit
3b30157198
3 changed files with 30 additions and 2 deletions
  1. 13 2
      hide/comp/SceneEditor.hx
  2. 1 0
      hrt/impl/EditorTools.hx
  3. 16 0
      hrt/prefab/Object3D.hx

+ 13 - 2
hide/comp/SceneEditor.hx

@@ -172,6 +172,17 @@ class ViewportOverlaysPopup extends hide.comp.Popup {
 					var val = !ide.show3DIconsCategory.get(k);
 					var val = !ide.show3DIconsCategory.get(k);
 					ide.show3DIconsCategory.set(k, val);
 					ide.show3DIconsCategory.set(k, val);
 					js.Browser.window.localStorage.setItem(hrt.impl.EditorTools.iconVisibilityKey(k), val ? "true" : "false");
 					js.Browser.window.localStorage.setItem(hrt.impl.EditorTools.iconVisibilityKey(k), val ? "true" : "false");
+
+					if (k.match(hrt.impl.EditorTools.IconCategory.Object3D)) {
+						for (p in editor.sceneData.all()) {
+							var obj3D = Std.downcast(p, Object3D);
+
+							if (obj3D != null) {
+								obj3D.removeEditorUI();
+								obj3D.addEditorUI();
+							}
+						}
+					}
 				});
 				});
 				allIcons.append(input);
 				allIcons.append(input);
 				allIcons.append(new Element('<label for="$k" class="left">$k</label>'));
 				allIcons.append(new Element('<label for="$k" class="left">$k</label>'));
@@ -1947,7 +1958,7 @@ class SceneEditor {
 
 
 		cameraController2D = makeCamController2D();
 		cameraController2D = makeCamController2D();
 		cameraController2D.onClick = cameraController.onClick;
 		cameraController2D.onClick = cameraController.onClick;
-		
+
 		if (camera2D) {
 		if (camera2D) {
 			var cam2d = @:privateAccess view.getDisplayState("Camera2D");
 			var cam2d = @:privateAccess view.getDisplayState("Camera2D");
 			if( cam2d != null ) {
 			if( cam2d != null ) {
@@ -3938,7 +3949,7 @@ class SceneEditor {
 
 
 	function roundSmall(f: Float) {
 	function roundSmall(f: Float) {
 		var num = 10_000.0;
 		var num = 10_000.0;
-		var r = hxd.Math.round(f * num) / num; 
+		var r = hxd.Math.round(f * num) / num;
 		// Avoid rounding floats that are too big
 		// Avoid rounding floats that are too big
 		return hxd.Math.abs(r-f) < 2.0 / num ? r : f;
 		return hxd.Math.abs(r-f) < 2.0 / num ? r : f;
 	}
 	}

+ 1 - 0
hrt/impl/EditorTools.hx

@@ -61,6 +61,7 @@ class Editor2DIcon extends h2d.ObjectFollower {
 enum IconCategory {
 enum IconCategory {
 	Light;
 	Light;
 	Trails;
 	Trails;
+	Object3D;
 	Audio;
 	Audio;
 	Misc;
 	Misc;
 }
 }

+ 16 - 0
hrt/prefab/Object3D.hx

@@ -216,6 +216,9 @@ class Object3D extends Prefab {
 			}
 			}
 		}
 		}
 
 
+		if (!hide.Ide.inst.show3DIconsCategory.get(hrt.impl.EditorTools.IconCategory.Object3D))
+			return;
+
 		// add ranges
 		// add ranges
 		var sheet = getCdbType();
 		var sheet = getCdbType();
 		if( sheet != null ) {
 		if( sheet != null ) {
@@ -305,6 +308,19 @@ class Object3D extends Prefab {
 		}
 		}
 	}
 	}
 
 
+	public function removeEditorUI() {
+		if (local3d != null) {
+			var objs = local3d.findAll((o) -> Std.downcast(o, h3d.scene.Object));
+			for (obj in objs) {
+				if (obj.name != null && StringTools.startsWith(obj.name,"$UI."))
+					obj.remove();
+			}
+		}
+
+		if (editorIcon != null)
+			editorIcon.removeChildren();
+	}
+
 	override function makeInteractive() : hxd.SceneEvents.Interactive {
 	override function makeInteractive() : hxd.SceneEvents.Interactive {
 		if(local3d == null)
 		if(local3d == null)
 			return null;
 			return null;