MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Spawn

Method Spawn

Source/Editor/Windows/SceneTreeWindow.cs:201–231  ·  view source on GitHub ↗
(Type type)

Source from the content-addressed store, hash-verified

199 }
200
201 private void Spawn(Type type)
202 {
203 // Create actor
204 Actor actor = (Actor)FlaxEngine.Object.New(type);
205 Actor parentActor = null;
206 if (Editor.SceneEditing.HasSthSelected && Editor.SceneEditing.Selection[0] is ActorNode actorNode)
207 {
208 parentActor = actorNode.Actor;
209 actorNode.TreeNode.Expand();
210 }
211 if (parentActor == null)
212 {
213 var scenes = Level.Scenes;
214 if (scenes.Length > 0)
215 parentActor = scenes[scenes.Length - 1];
216 }
217 if (parentActor != null)
218 {
219 // Use the same location
220 actor.Transform = parentActor.Transform;
221
222 // Rename actor to identify it easily
223 actor.Name = Utilities.Utils.IncrementNameNumber(type.Name, x => parentActor.GetChild(x) == null);
224 }
225
226 // Spawn it
227 Editor.SceneEditing.Spawn(actor, parentActor);
228
229 Editor.SceneEditing.Select(actor);
230 RenameSelection();
231 }
232
233 /// <summary>
234 /// Focuses search box.

Callers 1

OnDragDropMethod · 0.45

Calls 5

IncrementNameNumberMethod · 0.80
NewMethod · 0.45
ExpandMethod · 0.45
GetChildMethod · 0.45
SelectMethod · 0.45

Tested by

no test coverage detected