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

Method GetOrAddChild

Source/Engine/Level/Actor.cs:176–188  ·  view source on GitHub ↗

Finds the child actor of the given type or creates a new one. Type of the actor to search for. Includes any actors derived from the type. The child actor.

()

Source from the content-addressed store, hash-verified

174 /// <typeparam name="T">Type of the actor to search for. Includes any actors derived from the type.</typeparam>
175 /// <returns>The child actor.</returns>
176 public T GetOrAddChild<T>() where T : Actor
177 {
178 var result = GetChild<T>();
179 if (result == null)
180 {
181 if (typeof(T).IsAbstract)
182 return null;
183
184 result = New<T>();
185 result.SetParent(this, false, false);
186 }
187 return result;
188 }
189
190 /// <summary>
191 /// Creates a new script of a specific type and adds it to the actor.

Callers

nothing calls this directly

Calls 1

SetParentMethod · 0.45

Tested by

no test coverage detected