- Home /
Unity increasing more than i want!
Hi, i created the simple code and put in OnGui:
if (Input.GetKeyDown(KeyCode.N))
{
if(nextDialog < 40)
{
dialogText = dialogTextVector[nextDialog];
nextDialog++;
}
}
But when i get the key N down, the code actually does nextDialog += 2.. that means, the number go 2 by 2, not 1 by 1.. Why this happens? And why if i put this command in function Update () doesn`t work?
Thanks Guys.
Answer by DaveA · Jan 13, 2014 at 09:10 AM
Don't check for Input in OnGUI. Do that in Update. OnGUI gets called several times per frame, Update is called once per frame. You might want to post your Update code so we can see why that didn't work for you.
Thanks man! I`m an idiot! I just saw that i was writing my code in On$$anonymous$$ouseDown() code and not Update (). But thanks to you i saw my mistake. Thanks and sorry for such an idiot mistake. =]
Your answer
