Add helper FindScript<T> and FindActor<T> to Actor

This commit is contained in:
Wojtek Figat
2021-07-26 21:32:00 +02:00
parent 6718b37ca1
commit 277e31c5dd

View File

@@ -224,6 +224,26 @@ namespace FlaxEngine
return script != null;
}
/// <summary>
/// Tries to find the script of the given type in this actor hierarchy (checks this actor and all children hierarchy).
/// </summary>
/// <typeparam name="T">Type of the object.</typeparam>
/// <returns>Script instance if found, null otherwise.</returns>
public T FindScript<T>() where T : Script
{
return FindScript(typeof(T)) as T;
}
/// <summary>
/// Tries to find the actor of the given type in this actor hierarchy (checks this actor and all children hierarchy).
/// </summary>
/// <typeparam name="T">Type of the object.</typeparam>
/// <returns>Actor instance if found, null otherwise.</returns>
public T FindActor<T>() where T : Actor
{
return FindActor(typeof(T)) as T;
}
/// <summary>
/// Searches for all actors of a specific type in this actor children list.
/// </summary>