- Home /
Input.anyKeyDown is disabled when in GUI Textfield - Help
Hello,
I have a Input.anyKeyDown in my script that basically plays a little chime when ever a button is pressed, although this function is disabled every time I click on my GUI textfield - thus the chime does not play when I type in the textfield. How can I prevent this from happening?
Audio control script (Snippets):
// --- Audio Control --- \\ if(Input.anyKeyDown && typing == true){ TypingAudio(); }
}
private var typing : boolean = true;
function TypingAudio(){ typing = false; audio.clip = typingAudio; audio.Play(); yield WaitForSeconds(0.5); audio.Pause(); typing = true;
}
And the GUI script (snippet):
if(GUI.Button(Rect(30, 140, 50, 30),"Login")){
if(passwordInput == password){
ComputerControl.computerPass = false; //being called true somewhere
ComputerControl.computerActive = true; // might not be needed as is always true on this script
passwordOn = false;
clearGameCache();
}
else if(passwordInput != password){
GUI.Label (Rect (30, 50, 200, 20), "Password Incorrect!");
passwordInput = "";
}
}
Please help!
Thanks
Answer by Bunny83 · Feb 27, 2011 at 02:50 AM
Just do it with the GUI events. Inside OnGUI:
var event : Event = Event.current;
if (event.type == EventType.KeyDown)
{
// any key down
}
Your answer
Follow this Question
Related Questions
GUI.TextField duplicates texts on android. 0 Answers
Allow specific characters on GUI textField? 1 Answer
Re Enable C# script on camera 1 Answer
Using "fonts" that are actually images for a multi-outline effect. 2 Answers
Dialouge text. 1 Answer