Menus - KitchenMods/KitchenLib GitHub Wiki
KitchenLib provides a ModPreferences
menu for mods to use, this menu can be added to by:
Registering Your Menu
Events.PreferenceMenu_PauseMenu_CreateSubmenusEvent += (s, args) => {
args.Menus.Add(typeof(YourMenu<MainMenuAction>), new YourMenu<MainMenuAction>(args.Container, args.Module_list));
args.Menus.Add(typeof(YourMenu<PauseMenuAction>), new YourMenu<PauseMenuAction>(args.Container, args.Module_list));
};
Adding Your Menu
ModsPreferencesMenu<MainMenuAction>.RegisterMenu("Your Menu", typeof(YourMenu<MainMenuAction>), typeof(MainMenuAction));
ModsPreferencesMenu<PauseMenuAction>.RegisterMenu("Your Menu", typeof(YourMenu<PauseMenuAction>), typeof(PauseMenuAction));
KitchenLib builds a UnityGUI menu which can be accessed in-game when pressing CTRL + Left Shift + T
.
Mods are given a space in this menu which they're able to draw in. ( As seen by the Materials menu )
To create a menu, you need to make a class based off BaseUI
public class MyMenu : BaseUI
{
public MyMenu()
{
ButtonName = "My Menu!"; // Here I'm assigning the text to be displayed on the button.
}
public override void OnInit() { } // This is called as soon as the menu is attached
public override void OnDisable() { } // This is called when the menu is closed
public override void Setup() // This is called evey frame the menu is open, This is also where you draw your UnityGUI
{
GUILayout.Label("Hello World!");
}
}
You then need to register your new menu OnInitialise()
( Or for Workshop mods OnPostActivate(Mod mod)
)
protected override void OnPostActivate(Mod mod)
{
RegisterMenu<MyMenu>();
}