(Type type)
| 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. |
no test coverage detected