Merge branch 'Level' of https://github.com/MrCapy0/FlaxEngine into MrCapy0-Level
# Conflicts: # Source/Engine/Level/Level.cpp
This commit is contained in:
@@ -1617,13 +1617,16 @@ Array<Actor*> Level::GetActors(const MClass* type, bool activeOnly)
|
||||
return result;
|
||||
}
|
||||
|
||||
Array<Script*> Level::GetScripts(const MClass* type)
|
||||
Array<Script*> Level::GetScripts(const MClass* type, Actor* root)
|
||||
{
|
||||
Array<Script*> result;
|
||||
CHECK_RETURN(type, result);
|
||||
ScopeLock lock(ScenesLock);
|
||||
for (int32 i = 0; i < Scenes.Count(); i++)
|
||||
::GetScripts(type, type->IsInterface(), Scenes[i], result);
|
||||
const bool isInterface = type->IsInterface();
|
||||
if (root)
|
||||
::GetScripts(type, isInterface, root, result);
|
||||
else for (int32 i = 0; i < Scenes.Count(); i++)
|
||||
::GetScripts(type, isInterface, Scenes[i], result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace FlaxEngine
|
||||
{
|
||||
return FindActor(typeof(T)) as T;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Tries to find actor of the given type and name in all loaded scenes.
|
||||
/// </summary>
|
||||
@@ -77,7 +77,7 @@ 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>
|
||||
@@ -102,13 +102,14 @@ namespace FlaxEngine
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds all the scripts of the given type in all the loaded scenes.
|
||||
/// Finds all the scripts of the given type in an actor or all the loaded scenes.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Type of the object.</typeparam>
|
||||
/// <param name="root">The root to find scripts. If null, will search in all scenes</param>
|
||||
/// <returns>Found scripts list.</returns>
|
||||
public static T[] GetScripts<T>() where T : Script
|
||||
public static T[] GetScripts<T>(Actor root = null) where T : Script
|
||||
{
|
||||
var scripts = GetScripts(typeof(T));
|
||||
var scripts = GetScripts(typeof(T), root);
|
||||
if (typeof(T) == typeof(Script))
|
||||
return (T[])scripts;
|
||||
if (scripts.Length == 0)
|
||||
|
||||
@@ -469,11 +469,12 @@ public:
|
||||
API_FUNCTION() static Array<Actor*> GetActors(API_PARAM(Attributes="TypeReference(typeof(Actor))") const MClass* type, bool activeOnly = false);
|
||||
|
||||
/// <summary>
|
||||
/// Finds all the scripts of the given type in all the loaded scenes.
|
||||
/// Finds all the scripts of the given type in an actor or all the loaded scenes.
|
||||
/// </summary>
|
||||
/// <param name="type">Type of the script to search for. Includes any scripts derived from the type.</param>
|
||||
/// <param name="root">The root to find scripts. If null, will search in all scenes.</param>
|
||||
/// <returns>Found scripts list.</returns>
|
||||
API_FUNCTION() static Array<Script*> GetScripts(API_PARAM(Attributes="TypeReference(typeof(Script))") const MClass* type);
|
||||
API_FUNCTION() static Array<Script*> GetScripts(API_PARAM(Attributes="TypeReference(typeof(Script))") const MClass* type, Actor* root = nullptr);
|
||||
|
||||
/// <summary>
|
||||
/// Tries to find scene with given ID.
|
||||
|
||||
Reference in New Issue
Block a user