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.
()
| 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. |