- Home /
[fixed]enum change to something if input and enum is something
I have this script and I can't get it to work, it is pretty simple. it is for a GUIMenu wher you can turn on Q and E. Here's the script:
enum currentMenu{isTime, isMaps, isBattery};
private var isTime = currentMenu.isTime;
private var isMaps = currentMenu.isMaps;
private var isBattery = currentMenu.isBattery;
private var menu : currentMenu;
if (Input.GetKeyUp(KeyCode.Q)){
if (menu == isBattery){
menu = isMaps;
}
if (menu == isMaps){
menu = isTime;
}
if (menu == isTime){
menu = isBattery;
}
}
if (Input.GetKeyUp(KeyCode.E)){
if (menu == isBattery){
menu = isTime;
}
if (menu == isTime){
menu = isMaps;
}
if (menu == isMaps){
menu = isBattery;
}
}
The problem was that I needed to put in some booleans, they only changed while i got the key up.
Comment
Best Answer
Answer by fafase · Apr 28, 2013 at 10:05 AM
When you compare enum you need to use the type:
if (menu == currentMenu.isBattery){
menu = currentMenu.isMaps;
}
and like this all the way. You should also give a default value to your enum. If you don't want to assign any just add default in your enum that would stand for none of them.