diff --git a/editor/src/com/talosvfx/talos/editor/addons/scene/SceneEditorWorkspace.java b/editor/src/com/talosvfx/talos/editor/addons/scene/SceneEditorWorkspace.java index b3ea10c4a..8dd49b7b0 100644 --- a/editor/src/com/talosvfx/talos/editor/addons/scene/SceneEditorWorkspace.java +++ b/editor/src/com/talosvfx/talos/editor/addons/scene/SceneEditorWorkspace.java @@ -1119,38 +1119,30 @@ public void onGameObjectSelectionChanged (GameObjectSelectionChanged event) { if (event.get().size == 1) { //Only select gizmos if one is selected selectGizmos(gameObjects); - } else { + } else if(event.get().size > 1){ unselectGizmos(); groupSelectionGizmo.setSelected(true); + showPropertyPanelForGameObjects(gameObjects); } // now for properties - if (gameObjects.size == 0) { - // we select the main container then - if (currentContainer instanceof Scene) { - Scene scene = (Scene) currentContainer; - selectPropertyHolder(PropertyWrapperProviders.getOrCreateHolder(scene)); - } else if (currentContainer instanceof Prefab) { - Prefab prefab = (Prefab) currentContainer; - selectPropertyHolder(PropertyWrapperProviders.getOrCreateHolder(prefab)); - } - } else { + mapEditorState.update(event); + } + + public void showPropertyPanelForGameObjects(ObjectSet gameObjects) { if (gameObjects.size == 1) { selectPropertyHolder(PropertyWrapperProviders.getOrCreateHolder(gameObjects.first())); - } else { + } else if(gameObjects.size > 1){ ObjectSet tempList = new ObjectSet<>(); for (GameObject gameObject : gameObjects) { tempList.add(PropertyWrapperProviders.getOrCreateHolder(gameObject)); } selectPropertyHolder(PropertyWrapperProviders.getOrCreateHolder(new MultiPropertyHolder<>(tempList))); - if(aligningToolsPane.getParent() == null) { + if (aligningToolsPane.getParent() == null) { groupSelectionGizmo.getViewportWidget().addActor(aligningToolsPane); } } - } - - mapEditorState.update(event); } @EventHandler @@ -1500,11 +1492,22 @@ public void performSelectionClear() { Notifications.fireEvent(gameObjectSelectionChanged); } - @EventHandler - public void onGameAssetOpened (GameAssetOpenEvent gameAssetOpenEvent) { - GameAsset gameAsset = gameAssetOpenEvent.getGameAsset(); - if (gameAsset.type == GameAssetType.SCENE) { - this.gameAsset = (GameAsset) gameAsset; + @Override + protected void onGizmoTouch(Gizmo hitGizmo, float x, float y, int button) { + super.onGizmoTouch(hitGizmo, x, y, button); + showPropertyPanelForGameObjects(selection); + } + + @Override + protected void onEmptyAreaTouch() { + super.onEmptyAreaTouch(); + + if (currentContainer instanceof Scene) { + Scene scene = (Scene) currentContainer; + selectPropertyHolder(PropertyWrapperProviders.getOrCreateHolder(scene)); + } else if (currentContainer instanceof Prefab) { + Prefab prefab = (Prefab) currentContainer; + selectPropertyHolder(PropertyWrapperProviders.getOrCreateHolder(prefab)); } } } diff --git a/editor/src/com/talosvfx/talos/editor/addons/scene/widgets/PropertyPanel.java b/editor/src/com/talosvfx/talos/editor/addons/scene/widgets/PropertyPanel.java index 484040fa4..4f148c6f3 100644 --- a/editor/src/com/talosvfx/talos/editor/addons/scene/widgets/PropertyPanel.java +++ b/editor/src/com/talosvfx/talos/editor/addons/scene/widgets/PropertyPanel.java @@ -96,6 +96,8 @@ public void onMetaDataReloadedEvent (MetaDataReloadedEvent event) { } public void showPanel (IPropertyHolder target, Iterable propertyProviders) { + if (currentPropertyHolder != null && currentPropertyHolder.equals(target)) + return; providerSet.clear(); for(IPropertyProvider propertyProvider: propertyProviders) { if(propertyProvider.getType() == null) continue; diff --git a/editor/src/com/talosvfx/talos/editor/widgets/ui/ViewportWidget.java b/editor/src/com/talosvfx/talos/editor/widgets/ui/ViewportWidget.java index c2f58ab4a..226c76019 100644 --- a/editor/src/com/talosvfx/talos/editor/widgets/ui/ViewportWidget.java +++ b/editor/src/com/talosvfx/talos/editor/widgets/ui/ViewportWidget.java @@ -454,7 +454,7 @@ public boolean touchDown (InputEvent event, float x, float y, int pointer, int b hitGizmo = hitGizmoGameObject(hitCords.x, hitCords.y, selection.first()); if (hitGizmo != null) { - hitGizmo.touchDown(hitCords.x, hitCords.y, button); + onGizmoTouch(hitGizmo, hitCords.x, hitCords.y, button); } event.stop(); @@ -469,7 +469,7 @@ public boolean touchDown (InputEvent event, float x, float y, int pointer, int b hitGizmo = testGizmo; - hitGizmo.touchDown(hitCords.x, hitCords.y, button); + onGizmoTouch(hitGizmo, hitCords.x, hitCords.y, button); event.stop(); return true; @@ -489,11 +489,13 @@ public boolean touchDown (InputEvent event, float x, float y, int pointer, int b selectGameObject(entityUnderMouse); if (hitGizmo != null) { - hitGizmo.touchDown(hitCords.x, hitCords.y, button); + onGizmoTouch(hitGizmo, hitCords.x, hitCords.y, button); } getStage().setKeyboardFocus(ViewportWidget.this); event.handle(); return true; + }else{ + onEmptyAreaTouch(); } } @@ -513,7 +515,7 @@ public boolean touchDown (InputEvent event, float x, float y, int pointer, int b selectGameObject(touchDownedGameObject); if (hitGizmo != null) { - hitGizmo.touchDown(hitCords.x, hitCords.y, button); + onGizmoTouch(hitGizmo, hitCords.x, hitCords.y, button); } getStage().setKeyboardFocus(ViewportWidget.this); event.handle(); @@ -524,11 +526,12 @@ public boolean touchDown (InputEvent event, float x, float y, int pointer, int b if (canTouchGizmo(hitGizmo)) { selectGameObject(hitGizmo.getGameObject()); - - hitGizmo.touchDown(hitCords.x, hitCords.y, button); + onGizmoTouch(hitGizmo, hitCords.x, hitCords.y, button); getStage().setKeyboardFocus(ViewportWidget.this); event.handle(); return true; + } else { + onEmptyAreaTouch(); } } @@ -1400,4 +1403,11 @@ public void moveSelectedObjectsByPixels (float x, float y) { } SceneUtils.componentBatchUpdated(selection.orderedItems().get(0).getGameObjectContainerRoot(), selection.orderedItems(), TransformComponent.class, false); } + + protected void onGizmoTouch(Gizmo hitGizmo, float x, float y, int button) { + hitGizmo.touchDown(x, y, button); + } + + protected void onEmptyAreaTouch() { + } }