Skip to main content

Creating your own Menu Options

Introduction

qASIC comes with built in Menu Options, but if they aren't enough you can create your own. By inheriting the Menu Option class you can make your interactables change settings in the game.

Creating your own MenuOptions

To create a Menu Option you have to inherit the Menu Option class. It is a base for assigning labels and tags to your interactable.

You will need to override Load Option (where you assign the correct value to your interactable) and GetLabel (where you return the label that will be displayed).

using qASIC.Options.Menu;

public class OptionsExample : MenuOption
{
private Button button;

private void Awake()
{
button = GetComponent<Button>();
if (_button != null)
button.onClick.AddListener(OnButtonClick);
}

void OnButtonClick()
{
//Handle OnClick
}

public override string GetLabel()
{
//This is where you return the label
string value = "Insert value here";
return $"{optionLabelName}{value}";
}

public override void LoadOption()
{
//Assign the correct value to your interactable
}
}

Methods

MethodDescription
LoadOptionAssigns a value to the interactable.
SetValueChanges the value of the targeted setting.
GetLabelReturns the label that will be displayed in the menu.

Properties

PropertyDescription
nameTextA TMPro Text that will display the label.
optionLabelNameText that will be displayed before the value in the label.
optionNameName of the option
saveIf the setting should be saved when changing.