Merge branch 'add-activeOnly-to-getactors' of https://github.com/RuanLucasGD/FlaxEngine into RuanLucasGD-add-activeOnly-to-getactors
This commit is contained in:
@@ -1565,12 +1565,14 @@ Script* Level::FindScript(const MClass* type)
|
||||
|
||||
namespace
|
||||
{
|
||||
void GetActors(const MClass* type, Actor* actor, Array<Actor*>& result)
|
||||
void GetActors(const MClass* type, Actor* actor, bool activeOnly, Array<Actor*>& result)
|
||||
{
|
||||
if (activeOnly && !actor->GetIsActive())
|
||||
return;
|
||||
if (actor->GetClass()->IsSubClassOf(type))
|
||||
result.Add(actor);
|
||||
for (auto child : actor->Children)
|
||||
GetActors(type, child, result);
|
||||
GetActors(type, child, activeOnly, result);
|
||||
}
|
||||
|
||||
void GetScripts(const MClass* type, Actor* actor, Array<Script*>& result)
|
||||
@@ -1583,13 +1585,13 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
Array<Actor*> Level::GetActors(const MClass* type)
|
||||
Array<Actor*> Level::GetActors(const MClass* type, bool activeOnly)
|
||||
{
|
||||
Array<Actor*> result;
|
||||
CHECK_RETURN(type, result);
|
||||
ScopeLock lock(ScenesLock);
|
||||
for (int32 i = 0; i < Scenes.Count(); i++)
|
||||
::GetActors(type, Scenes[i], result);
|
||||
::GetActors(type, Scenes[i], activeOnly, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user