Add find actor by type and tag to level and actor classes. Move find actor by tag code to be by other find actor methods.

This commit is contained in:
Chandler Cox
2023-07-05 14:00:07 -05:00
parent bd0bc42adc
commit d88b93d56b
6 changed files with 240 additions and 137 deletions

View File

@@ -77,6 +77,18 @@ namespace FlaxEngine
{
return FindActor(typeof(T), name) as T;
}
/// <summary>
/// Tries to find actor of the given type and tag in a root actor or all loaded scenes.
/// </summary>
/// <param name="tag">A tag on the object.</param>
/// <param name="root">The custom root actor to start searching from (hierarchical), otherwise null to search all loaded scenes.</param>
/// <typeparam name="T">Type of the object.</typeparam>
/// <returns>Found actor or null.</returns>
public static T FindActor<T>(Tag tag, Actor root = null) where T : Actor
{
return FindActor(typeof(T), tag, root) as T;
}
/// <summary>
/// Tries to find actor with the given ID in all loaded scenes. It's very fast O(1) lookup.