diff --git a/Source/Editor/Modules/PrefabsModule.cs b/Source/Editor/Modules/PrefabsModule.cs
index 7b3ffebb3..b0be909fa 100644
--- a/Source/Editor/Modules/PrefabsModule.cs
+++ b/Source/Editor/Modules/PrefabsModule.cs
@@ -109,6 +109,27 @@ namespace FlaxEditor.Modules
Editor.Windows.ContentWin.NewItem(proxy, actor, OnPrefabCreated, actor.Name, rename);
}
+ ///
+ /// Open a prefab in a Prefab Editor
+ ///
+ /// Whether the prefab was successfully opened in a Prefab Editor
+ public bool OpenPrefab()
+ {
+ var selection = Editor.SceneEditing.Selection.Where(x => x is ActorNode actorNode && actorNode.HasPrefabLink).ToList().BuildNodesParents();
+ if (selection.Count == 0 || !((ActorNode)selection[0]).Actor.HasPrefabLink)
+ return false;
+
+ var prefabId = ((ActorNode)selection[0]).Actor.PrefabID;
+ var item = Editor.Instance.ContentDatabase.Find(prefabId);
+
+ if(item != null)
+ {
+ Editor.Instance.ContentEditing.Open(item);
+ return true;
+ }
+ return false;
+ }
+
private void OnPrefabCreated(ContentItem contentItem)
{
if (contentItem is PrefabItem prefabItem)
diff --git a/Source/Editor/Options/InputOptions.cs b/Source/Editor/Options/InputOptions.cs
index e0a51622b..3df7a4be8 100644
--- a/Source/Editor/Options/InputOptions.cs
+++ b/Source/Editor/Options/InputOptions.cs
@@ -200,6 +200,9 @@ namespace FlaxEditor.Options
[EditorDisplay("Interface"), EditorOrder(2020)]
public InputBinding PreviousTab = new InputBinding(KeyboardKeys.Tab, KeyboardKeys.Control, KeyboardKeys.Shift);
+ [DefaultValue(Windows.SceneNodeDoubleClick.None)]
+ [EditorDisplay("Interface"), EditorOrder(2030)]
+ public Windows.SceneNodeDoubleClick DoubleClickSceneNode = Windows.SceneNodeDoubleClick.None;
#endregion
}
}
diff --git a/Source/Editor/Windows/SceneTreeWindow.ContextMenu.cs b/Source/Editor/Windows/SceneTreeWindow.ContextMenu.cs
index e48e59f80..442a774fb 100644
--- a/Source/Editor/Windows/SceneTreeWindow.ContextMenu.cs
+++ b/Source/Editor/Windows/SceneTreeWindow.ContextMenu.cs
@@ -133,14 +133,15 @@ namespace FlaxEditor.Windows
contextMenu.AddSeparator();
+ ActorNode actorNode = (ActorNode)Editor.SceneEditing.Selection[0];
b = contextMenu.AddButton("Create Prefab", Editor.Prefabs.CreatePrefab);
- b.Enabled = isSingleActorSelected &&
- ((ActorNode)Editor.SceneEditing.Selection[0]).CanCreatePrefab &&
+ b.Enabled = isSingleActorSelected && actorNode.CanCreatePrefab &&
Editor.Windows.ContentWin.CurrentViewFolder.CanHaveAssets;
- bool hasPrefabLink = canEditScene && isSingleActorSelected && (Editor.SceneEditing.Selection[0] as ActorNode).HasPrefabLink;
+ bool hasPrefabLink = canEditScene && isSingleActorSelected && actorNode.HasPrefabLink;
if (hasPrefabLink)
{
+ contextMenu.AddButton("Open Prefab", () => Editor.Prefabs.OpenPrefab());
contextMenu.AddButton("Select Prefab", Editor.Prefabs.SelectPrefab);
contextMenu.AddButton("Break Prefab Link", Editor.Prefabs.BreakLinks);
}
diff --git a/Source/Editor/Windows/SceneTreeWindow.cs b/Source/Editor/Windows/SceneTreeWindow.cs
index 609f98f83..57bf4dad5 100644
--- a/Source/Editor/Windows/SceneTreeWindow.cs
+++ b/Source/Editor/Windows/SceneTreeWindow.cs
@@ -346,6 +346,29 @@ namespace FlaxEditor.Windows
return false;
}
+
+ ///
+ public override bool OnMouseDoubleClick(Float2 location, MouseButton button)
+ {
+ if(button == MouseButton.Left)
+ {
+ switch (Editor.Options.Options.Input.DoubleClickSceneNode)
+ {
+ case SceneNodeDoubleClick.Rename:
+ Rename();
+ return true;
+ case SceneNodeDoubleClick.Focus:
+ Editor.Windows.EditWin.Viewport.FocusSelection();
+ return true;
+ case SceneNodeDoubleClick.Open:
+ return Editor.Prefabs.OpenPrefab();
+ case SceneNodeDoubleClick.None:
+ default:
+ return base.OnMouseDoubleClick(location, button);
+ }
+ }
+ return base.OnMouseDoubleClick(location, button);
+ }
///
public override void OnLostFocus()
@@ -459,4 +482,28 @@ namespace FlaxEditor.Windows
base.OnDestroy();
}
}
+
+ ///
+ /// Action to perform when a Scene Node receive a double mouse click (Left)
+ ///
+ [Serializable]
+ public enum SceneNodeDoubleClick
+ {
+ ///
+ /// No action is performed
+ ///
+ None,
+ ///
+ /// Rename the Scene Node
+ ///
+ Rename,
+ ///
+ /// Focus the Scene Node object in the Scene View
+ ///
+ Focus,
+ ///
+ /// If possible, open the scene node in an associated Editor (e.g. Prefab Editor)
+ ///
+ Open
+ }
}