- Home /
Turn Off int using Boolean
Hello Everyone, sorry i'm always ask a question in unityanswers
Why does everytime i want to turn off the int using boolean, debug says "cannot convert int to boolean". How do i turn off the int? it's so annoying
and this is the example of my script currentMenuItem is Int, and menuToggle is Bool
function Update (){
if(!menuToggle){
menuItems[currentMenuItem].OnSelected(false);
if(settingsToggle){
currentMenuItem = 3; //i've got Array index is out of range.
}
}
if(!settingsToggle){
menuItemz[currentMenuItemz].OnSelected(false);
}
}
and this is the video http://www.youtube.com/watch?v=2MqQOhmns-Y
thank you very much for the reply. I really need this
Answer by syclamoth · Nov 04, 2011 at 02:47 PM
Well, if you're trying to convert a number into a 'true or false' value, that's going to happen. I'm afraid from your code, it's not especially clear what's going on here! I con't know what menuItems is, or where exactly you are trying to do what you are trying to do.
The 'Array index out of range' exception happens if you try to access a variable which is either smaller than zero, or greater than the highest index in the array. An array is indexed from 0 - (size - 1)- if your array is 3 long, the first one will be indexed '0', and the last one will be indexed '2'. It's possible that this is what is confusing you here.
I'm afraid that video you posted along with the question sheds absolutely no light on what the problem might be.
Basically, you can't 'deactivate' an int. What are you trying to do, stop the number from existing? That does't really make any sense. I'm sure what you're trying to do is possible, but the method you are chasing here is a dead end. Please explain yourself a bit better, and I'm sure someone'll be able to help you find a better way.
thanks for the answer. :) menuItems is the array of menuTem and menuTem is the script of iTween this is the full script. http://answers.unity3d.com/questions/180458/3d-main-menu-problem.html now what i'm going to do is stop the main menu action while i'm pressing or on settings area, then when i press return (settings area) the settings area should stop moving, then the main menu back. as you can see on my video, main menu and settings are moving together. you know what i mean right <:)
Your answer
Follow this Question
Related Questions
Turn float to int 2 Answers
[SOLVED] Convert this line from string to int 1 Answer
Get the number of false bools in GameObject[] (array) 3 Answers