diff --git a/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs b/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs
index 9dc0b1719..cebbfc544 100644
--- a/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs
+++ b/Source/Editor/SceneGraph/GUI/ActorTreeNode.cs
@@ -293,21 +293,6 @@ namespace FlaxEditor.SceneGraph.GUI
}
}
- ///
- public override bool OnKeyDown(KeyboardKeys key)
- {
- if (IsFocused)
- {
- if (key == KeyboardKeys.F2)
- {
- StartRenaming();
- return true;
- }
- }
-
- return base.OnKeyDown(key);
- }
-
///
protected override DragDropEffect OnDragEnterHeader(DragData data)
{
diff --git a/Source/Editor/Windows/Assets/PrefabWindow.Hierarchy.cs b/Source/Editor/Windows/Assets/PrefabWindow.Hierarchy.cs
index afba74fbc..a37d88b61 100644
--- a/Source/Editor/Windows/Assets/PrefabWindow.Hierarchy.cs
+++ b/Source/Editor/Windows/Assets/PrefabWindow.Hierarchy.cs
@@ -163,7 +163,13 @@ namespace FlaxEditor.Windows.Assets
private void Rename()
{
- ((ActorNode)Selection[0]).TreeNode.StartRenaming();
+ var selection = Selection;
+ if (selection.Count != 0 && selection[0] is ActorNode actor)
+ {
+ if (selection.Count != 0)
+ Select(actor);
+ actor.TreeNode.StartRenaming();
+ }
}
///
diff --git a/Source/Editor/Windows/Assets/PrefabWindow.cs b/Source/Editor/Windows/Assets/PrefabWindow.cs
index 85a9a2cb9..3820e762c 100644
--- a/Source/Editor/Windows/Assets/PrefabWindow.cs
+++ b/Source/Editor/Windows/Assets/PrefabWindow.cs
@@ -184,6 +184,7 @@ namespace FlaxEditor.Windows.Assets
InputActions.Add(options => options.Paste, Paste);
InputActions.Add(options => options.Duplicate, Duplicate);
InputActions.Add(options => options.Delete, Delete);
+ InputActions.Add(options => options.Rename, Rename);
InputActions.Add(options => options.FocusSelection, _viewport.FocusSelection);
}
diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs
index afe6d977e..e930ff053 100644
--- a/Source/Editor/Windows/SceneTreeWindow.cs
+++ b/Source/Editor/Windows/SceneTreeWindow.cs
@@ -69,6 +69,7 @@ namespace FlaxEditor.Windows
InputActions.Add(options => options.RotateMode, () => Editor.MainTransformGizmo.ActiveMode = TransformGizmoBase.Mode.Rotate);
InputActions.Add(options => options.ScaleMode, () => Editor.MainTransformGizmo.ActiveMode = TransformGizmoBase.Mode.Scale);
InputActions.Add(options => options.FocusSelection, () => Editor.Windows.EditWin.Viewport.FocusSelection());
+ InputActions.Add(options => options.Rename, Rename);
}
private void OnSearchBoxTextChanged()
@@ -91,7 +92,13 @@ namespace FlaxEditor.Windows
private void Rename()
{
- (Editor.SceneEditing.Selection[0] as ActorNode).TreeNode.StartRenaming();
+ var selection = Editor.SceneEditing.Selection;
+ if (selection.Count != 0 && selection[0] is ActorNode actor)
+ {
+ if (selection.Count != 0)
+ Editor.SceneEditing.Select(actor);
+ actor.TreeNode.StartRenaming();
+ }
}
private void Spawn(Type type)