add optional parameter to find only active actors on Level.FinActors(tag)
This commit is contained in:
@@ -740,12 +740,14 @@ Actor* FindActorRecursive(Actor* node, const Tag& tag)
|
||||
return result;
|
||||
}
|
||||
|
||||
void FindActorsRecursive(Actor* node, const Tag& tag, Array<Actor*>& result)
|
||||
void FindActorsRecursive(Actor* node, const Tag& tag, const bool activeOnly, Array<Actor*>& result)
|
||||
{
|
||||
if (activeOnly && !node->GetIsActive())
|
||||
return;
|
||||
if (node->HasTag(tag))
|
||||
result.Add(node);
|
||||
for (Actor* child : node->Children)
|
||||
FindActorsRecursive(child, tag, result);
|
||||
FindActorsRecursive(child, tag, activeOnly, result);
|
||||
}
|
||||
|
||||
void FindActorsRecursiveByParentTags(Actor* node, const Array<Tag>& tags, Array<Actor*>& result)
|
||||
@@ -785,19 +787,19 @@ void FindActorRecursive(Actor* node, const Tag& tag, Array<Actor*>& result)
|
||||
FindActorRecursive(child, tag, result);
|
||||
}
|
||||
|
||||
Array<Actor*> Level::FindActors(const Tag& tag, Actor* root)
|
||||
Array<Actor*> Level::FindActors(const Tag& tag, const bool activeOnly, Actor* root)
|
||||
{
|
||||
PROFILE_CPU();
|
||||
Array<Actor*> result;
|
||||
if (root)
|
||||
{
|
||||
FindActorsRecursive(root, tag, result);
|
||||
FindActorsRecursive(root, tag, activeOnly, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScopeLock lock(ScenesLock);
|
||||
for (Scene* scene : Scenes)
|
||||
FindActorsRecursive(scene, tag, result);
|
||||
FindActorsRecursive(scene, tag, activeOnly, result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -494,9 +494,10 @@ public:
|
||||
/// Tries to find the actors with the given tag (returns all found).
|
||||
/// </summary>
|
||||
/// <param name="tag">The tag of the actor to search for.</param>
|
||||
/// <param name="activeOnly">Find only active actors.</param>
|
||||
/// <param name="root">The custom root actor to start searching from (hierarchical), otherwise null to search all loaded scenes.</param>
|
||||
/// <returns>Found actors or empty if none.</returns>
|
||||
API_FUNCTION() static Array<Actor*> FindActors(const Tag& tag, Actor* root = nullptr);
|
||||
API_FUNCTION() static Array<Actor*> FindActors(const Tag& tag, const bool activeOnly = false, Actor* root = nullptr);
|
||||
|
||||
/// <summary>
|
||||
/// Search actors using a parent parentTag.
|
||||
|
||||
Reference in New Issue
Block a user