Add set order in parent for spawning actor with a parent in editor.

This commit is contained in:
Chandler Cox
2025-04-07 21:10:36 -05:00
parent 4a10905464
commit 2452face38
5 changed files with 22 additions and 16 deletions

View File

@@ -310,8 +310,9 @@ namespace FlaxEditor.Modules
/// </summary>
/// <param name="actor">The actor.</param>
/// <param name="parent">The parent actor. Set null as default.</param>
/// <param name="orderInParent">The order under the parent to put the spawned actor.</param>
/// <param name="autoSelect">True if automatically select the spawned actor, otherwise false.</param>
public void Spawn(Actor actor, Actor parent = null, bool autoSelect = true)
public void Spawn(Actor actor, Actor parent = null, int orderInParent = -1, bool autoSelect = true)
{
bool isPlayMode = Editor.StateMachine.IsPlayMode;
@@ -323,6 +324,10 @@ namespace FlaxEditor.Modules
// Add it
Level.SpawnActor(actor, parent);
// Set order if given
if (orderInParent != -1)
actor.OrderInParent = orderInParent;
// Peek spawned node
var actorNode = Editor.Instance.Scene.GetActorNode(actor);
if (actorNode == null)
@@ -568,7 +573,7 @@ namespace FlaxEditor.Modules
{
Position = center,
};
Editor.SceneEditing.Spawn(parent, null, false);
Editor.SceneEditing.Spawn(parent, null, -1, false);
using (new UndoMultiBlock(Undo, actors, "Reparent actors"))
{
for (int i = 0; i < selection.Count; i++)