Ok so I’m using NGUI and it works great except every time I type a space, my character jumps because that’s also my jump key. And anytime I press W+A+S+D my character moves. I looked around online for a solution and can’t find anything. Why doesn’t NGUI block inputs automatically? Is there some checkbox to tell it not to? Thanks!
In case anyone else is looking for an answer to this, I solved this by interrupting my funtion that receives input for walking and jumping, using this code to perform the interruption:
if (UICamera.selectedObject != null) {
if (UICamera.selectedObject.name == "MyChatInput(Clone)") {
return; //if we are doing something with a NGUI element, then just exit here so we don't jump while typing.
};
};
Note that “UICamera” should be globally accessible from anywhere in your project, so you can add this code anywhere you need to.
Also note that the above code will still allow movement if the UIRoot is selected, which is probably what you want because the UIRoot shouldn’t be selectable to begin with, and for whatever reason, the game starts out with the UIRoot selected.
Just rename the “MyChatInput(Clone)” to whatever is the name of your game object that the user can select in your UI, such as an input box, and this code works for me.