From 913a87a6955b939c04a4943c0aa9904406df01f0 Mon Sep 17 00:00:00 2001 From: andruzzzhka Date: Tue, 15 May 2018 22:01:19 +0700 Subject: [PATCH] Copying plugins to .cache on launch, so mod gui can update original plugin files in-game --- IllusionInjector/PluginManager.cs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/IllusionInjector/PluginManager.cs b/IllusionInjector/PluginManager.cs index 4cb5d3a5..b44d6733 100644 --- a/IllusionInjector/PluginManager.cs +++ b/IllusionInjector/PluginManager.cs @@ -44,13 +44,28 @@ namespace IllusionInjector _Plugins = new List(); if (!Directory.Exists(pluginDirectory)) return; - + + if (!Directory.Exists(Path.Combine(pluginDirectory, ".cache"))) + { + Directory.CreateDirectory(Path.Combine(pluginDirectory, ".cache")); + } + else + { + foreach (string plugin in Directory.GetFiles(Path.Combine(pluginDirectory, ".cache"), "*")) + { + File.Delete(plugin); + } + } + String[] files = Directory.GetFiles(pluginDirectory, "*.dll"); - foreach (var s in files) + foreach (string s in files) { - _Plugins.AddRange(LoadPluginsFromFile(Path.Combine(pluginDirectory, s), exeName)); + + string pluginCopy = pluginDirectory + "\\.cache" + s.Substring(s.LastIndexOf('\\')); + File.Copy(Path.Combine(pluginDirectory, s), pluginCopy); + _Plugins.AddRange(LoadPluginsFromFile(pluginCopy, exeName)); } - + // DEBUG debugLogger.Log($"Running on Unity {UnityEngine.Application.unityVersion}");