Hello, I’m trying to do a text adventure game, but I’m faced upon doing it either by multiple scenes and OnClick script, or doing it with enum States. i would like to know if it is possible to change a state when a button is clicked. If it is, would you be so kind to enlighten me through it? As you may notice, I’m still a n00b in unity affairs.
If you’re using a UI Button you can just make a public function in your script with a parameter to pass it the enum to change the state to, and then call it in the button’s OnClick event in the inspector (if you have trouble finding that you can check out this post).
Here’s an example of what I mean by the public function:
public enum MyState { something, somethingElse, nothing };
MyState state; // variable
public void ChangeState(MyState newState)
{
// call this function from the OnClick of the button and give it a new state
state = newState;
}