Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1 - Make a private bool for the checkbox (since it's a toggle it needs to be bool)
- public class <menuname> : Script
- {
- private bool checkbox = false;
- 2 - Create the public menu and add a submenu
- public void Menu1(UIMenu menu)
- {
- var sub1 = _menuPool.AddSubMenu(menu, "Menu 1");
- for (int i = 0; i > 1; i++)
- {
- }
- 3 - Create the checkbox
- var checkbox1 = new UIMenuCheckboxItem("Checkbox 1", checkbox, "Description for Checkbox ~b~Checkbox 1");
- sub1.AddItem(checkbox1);
- checkbox1.Enabled = true;
- sub1.OnCheckboxChange += (sender, item, checked_) =>
- {
- if (checked_ == true) // change "(item == checkbox1)" to "(checked_ == true)"
- // essentials it checks if the checkbox has been checked or not, hence true or false
- {
- // if it's checked, this happens
- UI.Notify("~b~Checkbox1 ~w~= ~g~Checked ~w~(This is a notification)");
- UI.ShowSubtitle("~b~Checkbox1 ~w~= ~g~Checked ~w~(This is a subtitle)");
- }
- else if (checked_ == false)
- {
- // if it's not checked, this happens
- UI.Notify("~b~Checkbox1 ~w~= ~r~Not checked ~w~(This is a notification)");
- UI.ShowSubtitle("~b~Checkbox1 ~w~= ~r~Not checked ~w~(This is a subtitle)");
- }
- };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement