Example #1
0
        static bool OnToggle(UnityModManager.ModEntry modEntry, bool value)
        {
            if (value == enabled)
            {
                return(true);
            }
            enabled = value;

            if (enabled)
            {
                statsMenu = new GameObject().AddComponent <StatsMenu>();
                GameObject.DontDestroyOnLoad(statsMenu);
            }
            return(true);
        }
Example #2
0
        static bool OnToggle(UnityModManager.ModEntry modEntry, bool value)
        {
            Main.modEntry = modEntry;
            if (value == enabled)
            {
                return(true);
            }
            enabled = value;

            if (enabled)
            {
                harmony = new Harmony(modEntry.Info.Id);
                harmony.PatchAll(Assembly.GetExecutingAssembly());
                Main.statsMenu = new GameObject().AddComponent <StatsMenu>();
                GameObject.DontDestroyOnLoad(statsMenu);
            }
            else
            {
                harmony.UnpatchAll(harmony.Id);
                GameObject.DestroyImmediate(statsMenu.gameObject);
                statsMenu = null;
            }
            return(true);
        }