Merge branch 'xxSeys1-groupActors'
This commit is contained in:
@@ -555,10 +555,20 @@ namespace FlaxEditor.Modules
|
||||
/// </summary>
|
||||
public void CreateParentForSelectedActors()
|
||||
{
|
||||
Actor actor = new EmptyActor();
|
||||
Editor.SceneEditing.Spawn(actor, null, false);
|
||||
List<SceneGraphNode> selection = Editor.SceneEditing.Selection;
|
||||
var actors = selection.Where(x => x is ActorNode).Select(x => ((ActorNode)x).Actor);
|
||||
var actorsCount = actors.Count();
|
||||
if (actorsCount == 0)
|
||||
return;
|
||||
Vector3 center = Vector3.Zero;
|
||||
foreach (var actor in actors)
|
||||
center += actor.Position;
|
||||
center /= actorsCount;
|
||||
Actor parent = new EmptyActor
|
||||
{
|
||||
Position = center,
|
||||
};
|
||||
Editor.SceneEditing.Spawn(parent, null, false);
|
||||
using (new UndoMultiBlock(Undo, actors, "Reparent actors"))
|
||||
{
|
||||
for (int i = 0; i < selection.Count; i++)
|
||||
@@ -574,15 +584,15 @@ namespace FlaxEditor.Modules
|
||||
|
||||
// Put created node as child of the Parent Node of node
|
||||
int parentOrder = node.Actor.OrderInParent;
|
||||
actor.Parent = node.Actor.Parent;
|
||||
actor.OrderInParent = parentOrder;
|
||||
parent.SetParent(node.Actor.Parent, true, true);
|
||||
parent.OrderInParent = parentOrder;
|
||||
}
|
||||
node.Actor.Parent = actor;
|
||||
node.Actor.SetParent(parent, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Editor.SceneEditing.Select(actor);
|
||||
Editor.Scene.GetActorNode(actor).TreeNode.StartRenaming(Editor.Windows.SceneWin, Editor.Windows.SceneWin.SceneTreePanel);
|
||||
Editor.SceneEditing.Select(parent);
|
||||
Editor.Scene.GetActorNode(parent).TreeNode.StartRenaming(Editor.Windows.SceneWin, Editor.Windows.SceneWin.SceneTreePanel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -556,7 +556,7 @@ namespace FlaxEditor.Modules
|
||||
cm.AddSeparator();
|
||||
_menuEditSelectAll = cm.AddButton("Select all", inputOptions.SelectAll, Editor.SceneEditing.SelectAllScenes);
|
||||
_menuEditDeselectAll = cm.AddButton("Deselect all", inputOptions.DeselectAll, Editor.SceneEditing.DeselectAllScenes);
|
||||
_menuCreateParentForSelectedActors = cm.AddButton("Create parent for selected actors", Editor.SceneEditing.CreateParentForSelectedActors);
|
||||
_menuCreateParentForSelectedActors = cm.AddButton("Parent to new Actor", inputOptions.GroupSelectedActors, Editor.SceneEditing.CreateParentForSelectedActors);
|
||||
_menuEditFind = cm.AddButton("Find", inputOptions.Search, Editor.Windows.SceneWin.Search);
|
||||
cm.AddSeparator();
|
||||
cm.AddButton("Game Settings", () =>
|
||||
|
||||
@@ -160,6 +160,10 @@ namespace FlaxEditor.Options
|
||||
[EditorDisplay("Scene"), EditorOrder(573)]
|
||||
public InputBinding PilotActor = new InputBinding(KeyboardKeys.None);
|
||||
|
||||
[DefaultValue(typeof(InputBinding), "Ctrl+G")]
|
||||
[EditorDisplay("Scene"), EditorOrder(574)]
|
||||
public InputBinding GroupSelectedActors = new InputBinding(KeyboardKeys.G, KeyboardKeys.Control);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Tools
|
||||
|
||||
@@ -1432,6 +1432,7 @@ namespace FlaxEditor.Utilities
|
||||
inputActions.Add(options => options.SelectAll, Editor.Instance.SceneEditing.SelectAllScenes);
|
||||
inputActions.Add(options => options.DeselectAll, Editor.Instance.SceneEditing.DeselectAllScenes);
|
||||
inputActions.Add(options => options.Delete, Editor.Instance.SceneEditing.Delete);
|
||||
inputActions.Add(options => options.GroupSelectedActors, Editor.Instance.SceneEditing.CreateParentForSelectedActors);
|
||||
inputActions.Add(options => options.Search, () => Editor.Instance.Windows.SceneWin.Search());
|
||||
inputActions.Add(options => options.MoveActorToViewport, Editor.Instance.UI.MoveActorToViewport);
|
||||
inputActions.Add(options => options.AlignActorWithViewport, Editor.Instance.UI.AlignActorWithViewport);
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace FlaxEditor.Windows
|
||||
|
||||
contextMenu.AddSeparator();
|
||||
|
||||
b = contextMenu.AddButton("Create parent for selected actors", Editor.SceneEditing.CreateParentForSelectedActors);
|
||||
b = contextMenu.AddButton("Parent to new Actor", inputOptions.GroupSelectedActors, Editor.SceneEditing.CreateParentForSelectedActors);
|
||||
b.Enabled = canEditScene && hasSthSelected;
|
||||
|
||||
b = contextMenu.AddButton("Create Prefab", Editor.Prefabs.CreatePrefab);
|
||||
|
||||
Reference in New Issue
Block a user