Add incremental actors naming when spawning them in viewport

#501
This commit is contained in:
Wojtek Figat
2021-05-14 12:37:20 +02:00
parent 2dff188eac
commit 401bd1c125

View File

@@ -389,10 +389,11 @@ namespace FlaxEditor.Viewport
return;
// Create actor
var parent = Level.GetScene(0);
var actor = new Camera
{
StaticFlags = StaticFlags.None,
Name = "Camera",
Name = StringUtils.IncrementNameNumber("Camera", x => parent.GetChild(x) == null),
Transform = ViewTransform,
NearPlane = NearPlane,
FarPlane = FarPlane,
@@ -402,7 +403,7 @@ namespace FlaxEditor.Viewport
};
// Spawn
Editor.Instance.SceneEditing.Spawn(actor);
Editor.Instance.SceneEditing.Spawn(actor, parent);
}
private void OnBegin(RenderTask task, GPUContext context)
@@ -877,6 +878,8 @@ namespace FlaxEditor.Viewport
private void Spawn(Actor actor, ref Vector3 hitLocation)
{
actor.Position = PostProcessSpawnedActorLocation(actor, ref hitLocation);
var parent = actor.Parent ?? Level.GetScene(0);
actor.Name = StringUtils.IncrementNameNumber(actor.Name, x => parent.GetChild(x) == null);
Editor.Instance.SceneEditing.Spawn(actor);
Focus();
}