Improve #2100 and fix undo
This commit is contained in:
@@ -542,24 +542,27 @@ namespace FlaxEditor.Modules
|
||||
Actor actor = new EmptyActor();
|
||||
Editor.SceneEditing.Spawn(actor, null, false);
|
||||
List<SceneGraphNode> selection = Editor.SceneEditing.Selection;
|
||||
for (int i = 0; i < selection.Count; i++)
|
||||
var actors = selection.Where(x => x is ActorNode).Select(x => ((ActorNode)x).Actor);
|
||||
using (new UndoMultiBlock(Undo, actors, "Reparent actors"))
|
||||
{
|
||||
if (selection[i] is ActorNode node)
|
||||
for (int i = 0; i < selection.Count; i++)
|
||||
{
|
||||
if (node.ParentNode != node.ParentScene) // if parent node is not Scene
|
||||
if (selection[i] is ActorNode node)
|
||||
{
|
||||
if (selection.Contains(node.ParentNode))
|
||||
if (node.ParentNode != node.ParentScene) // If parent node is not a scene
|
||||
{
|
||||
return; // if parent and child nodes selected together, don't touch child nodes
|
||||
}
|
||||
else
|
||||
{ // put created node as child of the Parent Node of node
|
||||
if (selection.Contains(node.ParentNode))
|
||||
{
|
||||
return; // If parent and child nodes selected together, don't touch child nodes
|
||||
}
|
||||
|
||||
// Put created node as child of the Parent Node of node
|
||||
int parentOrder = node.Actor.OrderInParent;
|
||||
actor.Parent = node.Actor.Parent;
|
||||
actor.OrderInParent = parentOrder;
|
||||
}
|
||||
node.Actor.Parent = actor;
|
||||
}
|
||||
node.Actor.Parent = actor;
|
||||
}
|
||||
}
|
||||
Editor.SceneEditing.Select(actor);
|
||||
|
||||
@@ -549,13 +549,11 @@ namespace FlaxEditor.Modules
|
||||
_menuEditCut = cm.AddButton("Cut", inputOptions.Cut, Editor.SceneEditing.Cut);
|
||||
_menuEditCopy = cm.AddButton("Copy", inputOptions.Copy, Editor.SceneEditing.Copy);
|
||||
_menuEditPaste = cm.AddButton("Paste", inputOptions.Paste, Editor.SceneEditing.Paste);
|
||||
cm.AddSeparator();
|
||||
_menuCreateParentForSelectedActors = cm.AddButton("Create parent for selected actors", Editor.SceneEditing.CreateParentForSelectedActors);
|
||||
cm.AddSeparator();
|
||||
_menuEditDelete = cm.AddButton("Delete", inputOptions.Delete, Editor.SceneEditing.Delete);
|
||||
_menuEditDuplicate = cm.AddButton("Duplicate", inputOptions.Duplicate, Editor.SceneEditing.Duplicate);
|
||||
cm.AddSeparator();
|
||||
_menuEditSelectAll = cm.AddButton("Select all", inputOptions.SelectAll, Editor.SceneEditing.SelectAllScenes);
|
||||
_menuCreateParentForSelectedActors = cm.AddButton("Create parent for selected actors", Editor.SceneEditing.CreateParentForSelectedActors);
|
||||
_menuEditFind = cm.AddButton("Find", inputOptions.Search, Editor.Windows.SceneWin.Search);
|
||||
cm.AddSeparator();
|
||||
cm.AddButton("Game Settings", () =>
|
||||
|
||||
@@ -132,17 +132,13 @@ namespace FlaxEditor.Windows
|
||||
b = contextMenu.AddButton("Cut", inputOptions.Cut, Editor.SceneEditing.Cut);
|
||||
b.Enabled = canEditScene;
|
||||
|
||||
// Create a new hierarchy from selected actors
|
||||
// Create option
|
||||
|
||||
contextMenu.AddSeparator();
|
||||
|
||||
b = contextMenu.AddButton("Create parent for selected actors", Editor.SceneEditing.CreateParentForSelectedActors);
|
||||
b.Enabled = canEditScene && hasSthSelected;
|
||||
|
||||
// Prefab options
|
||||
|
||||
contextMenu.AddSeparator();
|
||||
|
||||
b = contextMenu.AddButton("Create Prefab", Editor.Prefabs.CreatePrefab);
|
||||
b.Enabled = isSingleActorSelected &&
|
||||
((ActorNode)Editor.SceneEditing.Selection[0]).CanCreatePrefab &&
|
||||
|
||||
Reference in New Issue
Block a user