- Home /
[Solved] Menus advancing/returning several at a time
edit: Kudos to my man perchik for getting me out of it with style.
Here's my code. It's bloated and horrible -- my attempt at a generic piece of code for all menus didn't pan out -- but that's not really the problem. (Though I'll gladly have a tip or two on the side.)
if (options) {
if (optionsSelected == 3) {
if (Input.GetKeyDown (controller.p1ButtonA) | Input.GetKeyDown (controller.p2ButtonA)) {
options = false;
sound = true;
}
}
}
if (sound) {
if (audioSelected == 4) {
if ((Input.GetKeyDown (controller.p1ButtonA) | Input.GetKeyDown (controller.p2ButtonA))) {
options = true;
sound = false;
}
}
}
In short, there's meant to be a "Back" item in the audio menu.
I think I get what happens -- the forward and back commands are both run in the same frame, and because I have a separate selector for each submenu (believe me, I tried), the "Back" item is triggered on the same keypress immediately after the audio menu is entered. The thing I can't figure out is how to set up my input so as to avoid this sort of keypress confusion.
edit: Well, I've tried a special coroutine for preventing double inputs...
IEnumerator DoubleInputPrevention() {
noPress = true;
yield return new WaitForSeconds (0.25f);
noPress = false;
}
...and now the opposite happens -- the menu is never entered, because noPress is already true by the time the code gets to the relevant block.
I'm out of ideas.
Please don't use silly tags like "rocking in chair back and forth crying"
I think you may need to elaborate on what you want to do. Perhaps the solution is as simple as saying else if(sound)
and that way when you set sound to true, it doesn't change before the second if
statement
"else"-ing it was what did it. A whole bunch of thanks and apologies for the silliness.