Fix order when pasting UI Controls

#487
This commit is contained in:
Wojtek Figat
2021-04-29 15:22:36 +02:00
parent c2afe0b6b2
commit d2ac0429d3
5 changed files with 49 additions and 9 deletions

View File

@@ -288,6 +288,13 @@ namespace FlaxEditor.SceneGraph
{
}
/// <summary>
/// Action called after pasting actor in editor.
/// </summary>
public virtual void PostPaste()
{
}
/// <inheritdoc />
protected override void OnParentChanged()
{

View File

@@ -25,5 +25,20 @@ namespace FlaxEditor.SceneGraph.Actors
if (Actor is UIControl uiControl)
DebugDraw.DrawWireBox(uiControl.Bounds, Color.BlueViolet);
}
/// <inheritdoc />
public override void PostPaste()
{
base.PostPaste();
var control = ((UIControl)Actor).Control;
if (control != null)
{
if (control.Parent != null)
control.Parent.PerformLayout();
else
control.PerformLayout();
}
}
}
}

View File

@@ -140,22 +140,27 @@ namespace FlaxEditor.Actions
for (int i = 0; i < nodeParents.Count; i++)
{
// Fix name collisions (only for parents)
var node = nodeParents[i];
var parent = node.Actor?.Parent;
if (parent != null)
{
// Fix name collisions
string name = node.Name;
Actor[] children = parent.Children;
if (children.Any(x => x.Name == name))
{
// Generate new name
node.Actor.Name = StringUtils.IncrementNameNumber(name, x => children.All(y => y.Name != x));
}
}
Editor.Instance.Scene.MarkSceneEdited(node.ParentScene);
}
for (int i = 0; i < nodeParents.Count; i++)
{
var node = nodeParents[i];
node.PostPaste();
}
}
/// <summary>