- Home /
How to use a global variable in javascript to set other variables data
I have a column of buttons that each have GUIStyle being set through the editor, but I want to be able to set certain things using a global variable. Is there some way I can create a "global" GUIStyle variable, and if that value is changed it is applied to all the other variables too? Or do I have to go through each variable for each button and set the same values for the same fields? I know I can do this in code anyway I want, but I was hoping there would be a way to have any value changes reflected in the editor.
$$anonymous$$eep a reference script with public var whatever: inside.
Use GetComponent to retrieve the values when they need it. Try to avoid doing this every frame.
I'm getting a little more familiar with Unity and wanted to revisit this to ask, what did you mean by "try to avoid doing this every frame"? How do you implement something outside of onGui and Update, which both execute every frame or more often?
Your answer
Follow this Question
Related Questions
What is the name of the guistyle to draw the preview buttons? 1 Answer
How to customize guistyle 0 Answers
Key for GUI.Button 2 Answers
Check if GUI.Button Location is....(javascript) 0 Answers
Creates object under itself, not parent 0 Answers