Refactor new scene tree double click feature to support both prefab and scene editing
#1502
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FlaxEditor.Content;
|
||||
using FlaxEditor.GUI.ContextMenu;
|
||||
using FlaxEditor.GUI.Drag;
|
||||
@@ -86,7 +85,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
{
|
||||
return Editor.Instance.CodeEditing.Actors.Get().Contains(actorType);
|
||||
}
|
||||
|
||||
|
||||
private static bool ValidateDragControlType(ScriptType controlType)
|
||||
{
|
||||
return Editor.Instance.CodeEditing.Controls.Get().Contains(controlType);
|
||||
@@ -171,7 +170,8 @@ namespace FlaxEditor.Windows.Assets
|
||||
var actor = item.OnEditorDrop(this);
|
||||
actor.Name = item.ShortName;
|
||||
_window.Spawn(actor);
|
||||
var graphNode = _window.Graph.Root.Find(actor);;
|
||||
var graphNode = _window.Graph.Root.Find(actor);
|
||||
;
|
||||
if (graphNode != null)
|
||||
graphNodes.Add(graphNode);
|
||||
}
|
||||
@@ -235,7 +235,8 @@ namespace FlaxEditor.Windows.Assets
|
||||
}
|
||||
actor.Name = actorType.Name;
|
||||
_window.Spawn(actor);
|
||||
var graphNode = _window.Graph.Root.Find(actor);;
|
||||
var graphNode = _window.Graph.Root.Find(actor);
|
||||
;
|
||||
if (graphNode != null)
|
||||
graphNodes.Add(graphNode);
|
||||
}
|
||||
@@ -290,7 +291,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
|
||||
// Basic editing options
|
||||
|
||||
var b = contextMenu.AddButton("Rename", Rename);
|
||||
var b = contextMenu.AddButton("Rename", RenameSelection);
|
||||
b.Enabled = isSingleActorSelected;
|
||||
|
||||
b = contextMenu.AddButton("Duplicate", Duplicate);
|
||||
@@ -414,7 +415,8 @@ namespace FlaxEditor.Windows.Assets
|
||||
contextMenu.Show(parent, location);
|
||||
}
|
||||
|
||||
private void Rename()
|
||||
/// <inheritdoc />
|
||||
public void RenameSelection()
|
||||
{
|
||||
var selection = Selection;
|
||||
if (selection.Count != 0 && selection[0] is ActorNode actor)
|
||||
@@ -425,6 +427,12 @@ namespace FlaxEditor.Windows.Assets
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void FocusSelection()
|
||||
{
|
||||
_viewport.FocusSelection();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Spawns the specified actor to the prefab (adds actor to root).
|
||||
/// </summary>
|
||||
@@ -468,7 +476,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
|
||||
// Spawn it
|
||||
Spawn(actor);
|
||||
Rename();
|
||||
RenameSelection();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace FlaxEditor.Windows.Assets
|
||||
/// </summary>
|
||||
/// <seealso cref="Prefab" />
|
||||
/// <seealso cref="FlaxEditor.Windows.Assets.AssetEditorWindow" />
|
||||
public sealed partial class PrefabWindow : AssetEditorWindowBase<Prefab>, IPresenterOwner
|
||||
public sealed partial class PrefabWindow : AssetEditorWindowBase<Prefab>, IPresenterOwner, ISceneContextWindow
|
||||
{
|
||||
private readonly SplitPanel _split1;
|
||||
private readonly SplitPanel _split2;
|
||||
@@ -212,8 +212,8 @@ 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);
|
||||
InputActions.Add(options => options.Rename, RenameSelection);
|
||||
InputActions.Add(options => options.FocusSelection, FocusSelection);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user