From f8b3d8df51664b115e9225a7bc0b13e917e47d1e Mon Sep 17 00:00:00 2001 From: Quit Date: Sat, 8 Dec 2018 13:38:55 +0100 Subject: [PATCH] Ignore non-constructable plugins --- IllusionInjector/PluginManager.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/IllusionInjector/PluginManager.cs b/IllusionInjector/PluginManager.cs index 2a7f836..c0af204 100644 --- a/IllusionInjector/PluginManager.cs +++ b/IllusionInjector/PluginManager.cs @@ -48,7 +48,7 @@ namespace IllusionInjector { _Plugins.AddRange(LoadPluginsFromFile(Path.Combine(pluginDirectory, s), exeName)); } - + // DEBUG Console.WriteLine("Running on Unity {0}", UnityEngine.Application.unityVersion); @@ -76,7 +76,7 @@ namespace IllusionInjector foreach (Type t in assembly.GetTypes()) { - if (t.GetInterface("IPlugin") != null) + if (IsValidPlugin(t)) { try { @@ -108,6 +108,14 @@ namespace IllusionInjector return plugins; } + private static bool IsValidPlugin(Type type) + { + return type.GetInterface("IPlugin") != null + && !type.IsAbstract + && !type.IsInterface + && type.GetConstructor(Type.EmptyTypes) != null; + } + public class AppInfo { [DllImport("kernel32.dll", CharSet = CharSet.Auto, ExactSpelling = false)]