Merge branch 'Double-Click-Scene-Node-Actions' of https://github.com/davevanegdom/FlaxEngine into davevanegdom-Double-Click-Scene-Node-Actions
# Conflicts: # Source/Editor/Modules/PrefabsModule.cs # Source/Editor/Windows/SceneTreeWindow.ContextMenu.cs
This commit is contained in:
@@ -105,6 +105,30 @@ namespace FlaxEditor.Modules
|
||||
Editor.Windows.ContentWin.NewItem(proxy, actor, contentItem => OnPrefabCreated(contentItem, actor, prefabWindow), actor.Name, rename);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a prefab editor window.
|
||||
/// </summary>
|
||||
///
|
||||
/// <returns>Whether the prefab was successfully opened in a Prefab Editor.</returns>
|
||||
public bool OpenPrefab(Guid prefabID = default)
|
||||
{
|
||||
if (prefabID == Guid.Empty)
|
||||
{
|
||||
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;
|
||||
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, Actor actor, Windows.Assets.PrefabWindow prefabWindow)
|
||||
{
|
||||
if (contentItem is PrefabItem prefabItem)
|
||||
|
||||
Reference in New Issue
Block a user