Recreate PluginContext on destroy (in case the entire scene is wiped by the game)

This commit is contained in:
Eusth 2017-02-17 18:33:50 +01:00
parent a0e2310b8a
commit 5e91d68167
3 changed files with 8 additions and 3 deletions

View file

@ -19,8 +19,7 @@ namespace IllusionInjector
private static void Bootstrapper_Destroyed()
{
var singleton = new GameObject("PluginManager");
singleton.AddComponent<PluginComponent>(); ;
PluginComponent.Create();
}
}
}

View file

@ -10,6 +10,11 @@ namespace IllusionInjector
private CompositePlugin plugins;
private bool freshlyLoaded = false;
public static PluginComponent Create()
{
return new GameObject("IPA_PluginManager").AddComponent<PluginComponent>();
}
void Awake()
{
DontDestroyOnLoad(gameObject);
@ -46,6 +51,8 @@ namespace IllusionInjector
void OnDestroy()
{
plugins.OnApplicationQuit();
Create();
}
void OnLevelWasLoaded(int level)

View file

@ -60,7 +60,6 @@ namespace IllusionInjector
Console.WriteLine(" {0}: {1}", plugin.Name, plugin.Version);
}
Console.WriteLine("-----------------------------");
}
private static IEnumerable<IPlugin> LoadPluginsFromFile(string file, string exeName)