Hello. I am using toolbars for the options menu in my game (difficulty, ship, etc.). How can I make it so that when a button is active, it activates a component in the NEXT scene? I could try to use “do not destroy on load” but that would also keep the GUI elements on the screen. Any ideas? Thanks.
You’ll need to track the state of the toolbar somewhere else, and use ‘do not destroy on load’ on the object that holds the state, instead of the object that holds the GUI script. In other words, in your GUI code, store the state information that the next scene needs to look at in a script on another object, which persists after the level load.
static var ModeInt = 0;
var ModeStrings : String[] = [];
function OnGUI() {
ModeInt = GUI.Toolbar (Rect (240, 270, 500, 50), ModeInt, ModeStrings);
}
function Update(){
if (ModeStrings==2) ArcadeOptions.Mode == 2;
}
and it does not work (with this I get no errors but nothing happens. If I change ArcadeOptions.Mode == 2 to ArcadeOptions.Mode =2 and I get the error “Assets/Scripts/Menu/Arcade.js(33,50): BCE0022: Cannot convert ‘int’ to ‘System.Type’.”
You definitely want the = (assignment) operator, not the == (equality test) operator. You don’t show the declaration of ArcadeOptions.Mode but, given the error, I assume it’s not an ‘int’ value…