コード例 #1
0
        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 (soundMod == null)
                {
                    soundMod = ModMenu.Instance.gameObject.AddComponent <SoundMod>();
                }
            }
            else
            {
                harmonyInstance.UnpatchAll(harmonyInstance.Id);
                soundMod = null;
                UnityEngine.Object.Destroy(ModMenu.Instance.gameObject.GetComponent <SoundMod>());
            }
            return(true);
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: pggonni/Skater-XL-mods
        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());
                soundMod = new GameObject().AddComponent <SoundMod>();
                GameObject.DontDestroyOnLoad(soundMod.gameObject);
            }
            else
            {
                harmony.UnpatchAll(harmony.Id);
                GameObject.Destroy(soundMod.gameObject);
                soundMod = null;
            }
            return(true);
        }