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
Method | Description |
---|---|
LoadOption | Assigns a value to the interactable. |
SetValue | Changes the value of the targeted setting. |
GetLabel | Returns the label that will be displayed in the menu. |
Properties
Property | Description |
---|---|
nameText | A TMPro Text that will display the label. |
optionLabelName | Text that will be displayed before the value in the label. |
optionName | Name of the option |
save | If the setting should be saved when changing. |