Add Actor::GetOrAddChild to C++
This commit is contained in:
@@ -222,6 +222,22 @@ public:
|
||||
return (T*)GetChild(T::GetStaticClass());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the child actor of the given type or creates a new one.
|
||||
/// </summary>
|
||||
/// <returns>The child actor.</returns>
|
||||
template<typename T>
|
||||
T* GetOrAddChild()
|
||||
{
|
||||
T* result = (T*)GetChild(T::GetStaticClass());
|
||||
if (!result)
|
||||
{
|
||||
result = New<T>();
|
||||
result->SetParent(this, false, false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the child actors of the given type.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user