From f688cd0c69be3b299979db93b741921bc7d1d01a Mon Sep 17 00:00:00 2001 From: honzapatCZ Date: Thu, 18 Mar 2021 18:23:17 +0100 Subject: [PATCH 1/2] prefab first --- Source/Editor/Gizmo/TransformGizmo.cs | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/Source/Editor/Gizmo/TransformGizmo.cs b/Source/Editor/Gizmo/TransformGizmo.cs index afda8484e..08dbaaf3e 100644 --- a/Source/Editor/Gizmo/TransformGizmo.cs +++ b/Source/Editor/Gizmo/TransformGizmo.cs @@ -50,6 +50,44 @@ namespace FlaxEditor.Gizmo { } + /// + /// Helper function, recursivily finds the Prefab Root of node or null + /// + /// The node from which to start + /// + public ActorNode GetPrefabRootInParent(ActorNode node) + { + if (!node.HasPrefabLink) + return null; + if (node.Actor.IsPrefabRoot) + return node; + else if (node.ParentNode is ActorNode parAct) + return GetPrefabRootInParent(parAct); + else + return null; + } + + /// + /// Recursively walks up from the node up to ceiling node(inclusive) or selection(exclusive) + /// + /// The node from which to start + /// The ceiling(inclusive) + /// + public ActorNode RecursiveWalkUpAndFindSomethingBeforeSelectedOrSupplied(ActorNode node, ActorNode ceiling) + { + if (node == ceiling) + return node; + if (node.ParentNode is ActorNode parAct) + { + if (Editor.Instance.SceneEditing.Selection.Contains(node.ParentNode)) + return node; + else + return RecursiveWalkUpAndFindSomethingBeforeSelectedOrSupplied(parAct, ceiling); + } + else + return null; + } + /// public override void Pick() { @@ -100,6 +138,16 @@ namespace FlaxEditor.Gizmo } } + //select prefab root and then go down until you find the actual item in which case select the prefab root again + if(hit is ActorNode act) + { + ActorNode prefabRoot = GetPrefabRootInParent(act); + if (prefabRoot != null && act != prefabRoot) + { + hit = RecursiveWalkUpAndFindSomethingBeforeSelectedOrSupplied(act, prefabRoot); + } + } + bool addRemove = Owner.IsControlDown; bool isSelected = sceneEditing.Selection.Contains(hit); From f70b116fcbda87ad3b468e547370228d7566e3b2 Mon Sep 17 00:00:00 2001 From: honzapatCZ Date: Thu, 18 Mar 2021 19:18:59 +0100 Subject: [PATCH 2/2] renamed --- Source/Editor/Gizmo/TransformGizmo.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Editor/Gizmo/TransformGizmo.cs b/Source/Editor/Gizmo/TransformGizmo.cs index 08dbaaf3e..6040f0485 100644 --- a/Source/Editor/Gizmo/TransformGizmo.cs +++ b/Source/Editor/Gizmo/TransformGizmo.cs @@ -73,7 +73,7 @@ namespace FlaxEditor.Gizmo /// The node from which to start /// The ceiling(inclusive) /// - public ActorNode RecursiveWalkUpAndFindSomethingBeforeSelectedOrSupplied(ActorNode node, ActorNode ceiling) + public ActorNode WalkUpAndFindActorNodeBeforeSelection(ActorNode node, ActorNode ceiling) { if (node == ceiling) return node; @@ -82,7 +82,7 @@ namespace FlaxEditor.Gizmo if (Editor.Instance.SceneEditing.Selection.Contains(node.ParentNode)) return node; else - return RecursiveWalkUpAndFindSomethingBeforeSelectedOrSupplied(parAct, ceiling); + return WalkUpAndFindActorNodeBeforeSelection(parAct, ceiling); } else return null; @@ -144,7 +144,7 @@ namespace FlaxEditor.Gizmo ActorNode prefabRoot = GetPrefabRootInParent(act); if (prefabRoot != null && act != prefabRoot) { - hit = RecursiveWalkUpAndFindSomethingBeforeSelectedOrSupplied(act, prefabRoot); + hit = WalkUpAndFindActorNodeBeforeSelection(act, prefabRoot); } }