Various improvements

This commit is contained in:
Wojciech Figat
2022-09-07 11:53:03 +02:00
parent 7559cb4d99
commit 05064402b1
5 changed files with 32 additions and 5 deletions

View File

@@ -359,6 +359,22 @@ Plugin* PluginManager::GetPlugin(const MClass* type)
return nullptr;
}
Plugin* PluginManager::GetPlugin(const ScriptingTypeHandle& type)
{
CHECK_RETURN(type, nullptr);
for (Plugin* p : EditorPlugins)
{
if (p->Is(type))
return p;
}
for (GamePlugin* gp : GamePlugins)
{
if (gp->Is(type))
return gp;
}
return nullptr;
}
#if USE_EDITOR
void PluginManager::InitializeGamePlugins()

View File

@@ -7,7 +7,7 @@
/// <summary>
/// Game and Editor plugins management service.
/// </summary>
API_CLASS(Static) class PluginManager
API_CLASS(Static) class FLAXENGINE_API PluginManager
{
DECLARE_SCRIPTING_TYPE_NO_SPAWN(PluginManager);
public:
@@ -62,6 +62,13 @@ public:
/// <returns>The plugin or null.</returns>
API_FUNCTION() static Plugin* GetPlugin(API_PARAM(Attributes="TypeReference(typeof(Plugin))") const MClass* type);
/// <summary>
/// Returns the first plugin of the provided type.
/// </summary>
/// <param name="type">Type of the plugin to search for. Includes any plugin base class derived from the type.</param>
/// <returns>The plugin or null.</returns>
static Plugin* GetPlugin(const ScriptingTypeHandle& type);
/// <summary>
/// Returns the first plugin of the provided type.
/// </summary>
@@ -69,7 +76,7 @@ public:
template<typename T>
FORCE_INLINE static T* GetPlugin()
{
return (T*)GetPlugin(T::GetStaticClass());
return (T*)GetPlugin(T::TypeInitializer);
}
private: