Merge branch 'Tryibion-add-order-in-spawn'
This commit is contained in:
@@ -310,8 +310,9 @@ namespace FlaxEditor.Modules
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="actor">The actor.</param>
|
/// <param name="actor">The actor.</param>
|
||||||
/// <param name="parent">The parent actor. Set null as default.</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>
|
/// <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;
|
bool isPlayMode = Editor.StateMachine.IsPlayMode;
|
||||||
|
|
||||||
@@ -327,6 +328,10 @@ namespace FlaxEditor.Modules
|
|||||||
// Add it
|
// Add it
|
||||||
Level.SpawnActor(actor, parent);
|
Level.SpawnActor(actor, parent);
|
||||||
|
|
||||||
|
// Set order if given
|
||||||
|
if (orderInParent != -1)
|
||||||
|
actor.OrderInParent = orderInParent;
|
||||||
|
|
||||||
// Peek spawned node
|
// Peek spawned node
|
||||||
var actorNode = Editor.Instance.Scene.GetActorNode(actor);
|
var actorNode = Editor.Instance.Scene.GetActorNode(actor);
|
||||||
if (actorNode == null)
|
if (actorNode == null)
|
||||||
@@ -568,7 +573,7 @@ namespace FlaxEditor.Modules
|
|||||||
{
|
{
|
||||||
Position = center,
|
Position = center,
|
||||||
};
|
};
|
||||||
Editor.SceneEditing.Spawn(parent, null, false);
|
Editor.SceneEditing.Spawn(parent, null, -1, false);
|
||||||
using (new UndoMultiBlock(Undo, actors, "Reparent actors"))
|
using (new UndoMultiBlock(Undo, actors, "Reparent actors"))
|
||||||
{
|
{
|
||||||
for (int i = 0; i < selection.Count; i++)
|
for (int i = 0; i < selection.Count; i++)
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ namespace FlaxEditor.Modules
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Spawn(Actor actor, Actor parent)
|
public override void Spawn(Actor actor, Actor parent, int orderInParent = -1)
|
||||||
{
|
{
|
||||||
_editor.SceneEditing.Spawn(actor, parent);
|
_editor.SceneEditing.Spawn(actor, parent, orderInParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -690,9 +690,8 @@ namespace FlaxEditor.SceneGraph.GUI
|
|||||||
if (_dragAssets.Objects[i] is not PrefabItem)
|
if (_dragAssets.Objects[i] is not PrefabItem)
|
||||||
actor.Transform = Transform.Identity;
|
actor.Transform = Transform.Identity;
|
||||||
var previousTrans = actor.Transform;
|
var previousTrans = actor.Transform;
|
||||||
ActorNode.Root.Spawn(actor, spawnParent);
|
ActorNode.Root.Spawn(actor, spawnParent, newOrder);
|
||||||
actor.LocalTransform = previousTrans;
|
actor.LocalTransform = previousTrans;
|
||||||
actor.OrderInParent = newOrder;
|
|
||||||
}
|
}
|
||||||
result = DragDropEffect.Move;
|
result = DragDropEffect.Move;
|
||||||
}
|
}
|
||||||
@@ -710,8 +709,7 @@ namespace FlaxEditor.SceneGraph.GUI
|
|||||||
}
|
}
|
||||||
actor.StaticFlags = newParent.StaticFlags;
|
actor.StaticFlags = newParent.StaticFlags;
|
||||||
actor.Name = item.Name;
|
actor.Name = item.Name;
|
||||||
ActorNode.Root.Spawn(actor, newParent);
|
ActorNode.Root.Spawn(actor, newParent, newOrder);
|
||||||
actor.OrderInParent = newOrder;
|
|
||||||
}
|
}
|
||||||
result = DragDropEffect.Move;
|
result = DragDropEffect.Move;
|
||||||
}
|
}
|
||||||
@@ -733,8 +731,7 @@ namespace FlaxEditor.SceneGraph.GUI
|
|||||||
StaticFlags = newParent.StaticFlags,
|
StaticFlags = newParent.StaticFlags,
|
||||||
Name = item.Name,
|
Name = item.Name,
|
||||||
};
|
};
|
||||||
ActorNode.Root.Spawn(uiControl, newParent);
|
ActorNode.Root.Spawn(uiControl, newParent, newOrder);
|
||||||
uiControl.OrderInParent = newOrder;
|
|
||||||
}
|
}
|
||||||
result = DragDropEffect.Move;
|
result = DragDropEffect.Move;
|
||||||
}
|
}
|
||||||
@@ -761,8 +758,7 @@ namespace FlaxEditor.SceneGraph.GUI
|
|||||||
actor.StaticFlags = spawnParent.StaticFlags;
|
actor.StaticFlags = spawnParent.StaticFlags;
|
||||||
actor.Name = actorType.Name;
|
actor.Name = actorType.Name;
|
||||||
actor.Transform = spawnParent.Transform;
|
actor.Transform = spawnParent.Transform;
|
||||||
ActorNode.Root.Spawn(actor, spawnParent);
|
ActorNode.Root.Spawn(actor, spawnParent, newOrder);
|
||||||
actor.OrderInParent = newOrder;
|
|
||||||
}
|
}
|
||||||
else if (scriptType != ScriptType.Null)
|
else if (scriptType != ScriptType.Null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ namespace FlaxEditor.SceneGraph
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="actor">The actor.</param>
|
/// <param name="actor">The actor.</param>
|
||||||
/// <param name="parent">The parent.</param>
|
/// <param name="parent">The parent.</param>
|
||||||
public abstract void Spawn(Actor actor, Actor parent);
|
public abstract void Spawn(Actor actor, Actor parent, int orderInParent = -1);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the undo.
|
/// Gets the undo.
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void Spawn(Actor actor, Actor parent)
|
public override void Spawn(Actor actor, Actor parent, int orderInParent = -1)
|
||||||
{
|
{
|
||||||
_window.Spawn(actor, parent);
|
_window.Spawn(actor, parent, orderInParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -486,7 +486,8 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="actor">The actor.</param>
|
/// <param name="actor">The actor.</param>
|
||||||
/// <param name="parent">The parent.</param>
|
/// <param name="parent">The parent.</param>
|
||||||
public void Spawn(Actor actor, Actor parent)
|
/// <param name="orderInParent">The order of the actor under the parent.</param>
|
||||||
|
public void Spawn(Actor actor, Actor parent, int orderInParent = -1)
|
||||||
{
|
{
|
||||||
if (actor == null)
|
if (actor == null)
|
||||||
throw new ArgumentNullException(nameof(actor));
|
throw new ArgumentNullException(nameof(actor));
|
||||||
@@ -494,6 +495,10 @@ namespace FlaxEditor.Windows.Assets
|
|||||||
// Link it
|
// Link it
|
||||||
actor.Parent = parent ?? throw new ArgumentNullException(nameof(parent));
|
actor.Parent = parent ?? throw new ArgumentNullException(nameof(parent));
|
||||||
|
|
||||||
|
// Set order in parent
|
||||||
|
if (orderInParent != -1)
|
||||||
|
actor.OrderInParent = orderInParent;
|
||||||
|
|
||||||
// Peek spawned node
|
// Peek spawned node
|
||||||
var actorNode = SceneGraphFactory.FindNode(actor.ID) as ActorNode ?? SceneGraphFactory.BuildActorNode(actor);
|
var actorNode = SceneGraphFactory.FindNode(actor.ID) as ActorNode ?? SceneGraphFactory.BuildActorNode(actor);
|
||||||
if (actorNode == null)
|
if (actorNode == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user