static bool OnToggle(UnityModManager.ModEntry modEntry, bool value) { Main.modEntry = modEntry; if (enabled == value) { return(true); } enabled = value; if (enabled) { harmonyInstance = HarmonyInstance.Create(modEntry.Info.Id); harmonyInstance.PatchAll(Assembly.GetExecutingAssembly()); if (areYouSure == null) { areYouSure = ModMenu.Instance.gameObject.AddComponent <AreYouSure>(); } } else { harmonyInstance.UnpatchAll(harmonyInstance.Id); areYouSure = null; UnityEngine.Object.Destroy(ModMenu.Instance.gameObject.GetComponent <AreYouSure>()); } return(true); }
static bool OnToggle(UnityModManager.ModEntry modEntry, bool value) { Main.modEntry = modEntry; if (enabled == value) { return(true); } enabled = value; if (enabled) { // disable if xlshredmenu is detected var mod = UnityModManager.FindMod("blendermf.XLShredMenu"); if (mod != null) { modEntry.CustomRequirements = $"Mod {mod.Info.DisplayName} incompatible"; enabled = false; return(false); } harmony = new Harmony(modEntry.Info.Id); harmony.PatchAll(Assembly.GetExecutingAssembly()); if (areYouSure == null) { areYouSure = new GameObject().AddComponent <AreYouSure>(); GameObject.DontDestroyOnLoad(areYouSure.gameObject); } } else { harmony.UnpatchAll(harmony.Id); GameObject.Destroy(areYouSure.gameObject); areYouSure = null; } return(true); }
static bool Load(UnityModManager.ModEntry modEntry) { Main.modEntry = modEntry; areYouSure = ModMenu.Instance.gameObject.AddComponent <AreYouSure>(); modEntry.OnToggle = OnToggle; return(true); }