I want to save values within Unity's GUI. Except I'm not entirely sure how to retrieve the variables. For instance look at this function below.
public void sliderText (Slider s) {
Text t = s.GetComponentInChildren();
t.text = s.value.ToString();
}
It references a slider variable and a text variable. But those variables are confined within the function. So the only means of retrieving the variables are either putting a playerprefs function directly into the GUI function or declaring the variable you want to save in the script. The former would be fine if I didn't want to interact with the slider in order to save it. I want to tie saving it to an apply button which uses a different function. In the later case why even bother assigning the GUI function when you declare them as a variable? I had considered calling the variable by name and assigning them to the GUI's value. Except you would need a means of assigning them on awake for the playerprefs which as far as I'm aware that can only be done by declaring a variable and assigning it in the awake function. Is there something that I'm missing that could help me save the GUI functions variables?
↧