From 0628920fdf7dbcdfcdfc3b2bab74b83bfb6425b2 Mon Sep 17 00:00:00 2001 From: artman41 Date: Tue, 15 May 2018 16:15:07 +0100 Subject: [PATCH] - Had to split the interface as the old plugins couldn't be casted --- IllusionInjector/CompositePlugin.cs | 10 +++++++--- IllusionPlugin/IPlugin.cs | 21 --------------------- IllusionPlugin/IPluginNew.cs | 25 +++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 24 deletions(-) create mode 100644 IllusionPlugin/IPluginNew.cs diff --git a/IllusionInjector/CompositePlugin.cs b/IllusionInjector/CompositePlugin.cs index a2a30568..77614d35 100644 --- a/IllusionInjector/CompositePlugin.cs +++ b/IllusionInjector/CompositePlugin.cs @@ -1,6 +1,7 @@ using IllusionPlugin; using System; using System.Collections.Generic; +using System.Linq; using System.Text; using UnityEngine; using UnityEngine.SceneManagement; @@ -27,7 +28,8 @@ namespace IllusionInjector { } public void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode) { - foreach (var plugin in plugins) { + foreach (var plugin1 in plugins.Where(o => o is IPluginNew)) { + var plugin = (IPluginNew) plugin1; try { plugin.OnSceneLoaded(scene, sceneMode); } @@ -38,7 +40,8 @@ namespace IllusionInjector { } public void OnSceneUnloaded(Scene scene) { - foreach (var plugin in plugins) { + foreach (var plugin1 in plugins.Where(o => o is IPluginNew)) { + var plugin = (IPluginNew) plugin1; try { plugin.OnSceneUnloaded(scene); } @@ -49,7 +52,8 @@ namespace IllusionInjector { } public void OnActiveSceneChanged(Scene prevScene, Scene nextScene) { - foreach (var plugin in plugins) { + foreach (var plugin1 in plugins.Where(o => o is IPluginNew)) { + var plugin = (IPluginNew) plugin1; try { plugin.OnActiveSceneChanged(prevScene, nextScene); } diff --git a/IllusionPlugin/IPlugin.cs b/IllusionPlugin/IPlugin.cs index 34de5ef2..13338c7e 100644 --- a/IllusionPlugin/IPlugin.cs +++ b/IllusionPlugin/IPlugin.cs @@ -32,32 +32,11 @@ namespace IllusionPlugin /// void OnApplicationQuit(); - /// - /// Gets invoked whenever a scene is loaded. - /// - /// The scene currently loaded - /// The type of loading - void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode); - - /// - /// Gets invoked whenever a scene is unloaded - /// - /// The unloaded scene - void OnSceneUnloaded(Scene scene); - - /// - /// Gets invoked whenever a scene is changed - /// - /// The Scene that was previously loaded - /// The Scene being loaded - void OnActiveSceneChanged(Scene prevScene, Scene nextScene); - /// /// Gets invoked on every graphic update. /// void OnUpdate(); - /// /// Gets invoked on ever physics update. /// diff --git a/IllusionPlugin/IPluginNew.cs b/IllusionPlugin/IPluginNew.cs new file mode 100644 index 00000000..393dc2bc --- /dev/null +++ b/IllusionPlugin/IPluginNew.cs @@ -0,0 +1,25 @@ +using UnityEngine.SceneManagement; + +namespace IllusionPlugin { + public interface IPluginNew : IPlugin{ + /// + /// Gets invoked whenever a scene is loaded. + /// + /// The scene currently loaded + /// The type of loading + void OnSceneLoaded(Scene scene, LoadSceneMode sceneMode); + + /// + /// Gets invoked whenever a scene is unloaded + /// + /// The unloaded scene + void OnSceneUnloaded(Scene scene); + + /// + /// Gets invoked whenever a scene is changed + /// + /// The Scene that was previously loaded + /// The Scene being loaded + void OnActiveSceneChanged(Scene prevScene, Scene nextScene); + } +} \ No newline at end of file