- Home /
Touch and Button conflict
Hey guys, I am trying to do this in my project. I just wonder how do I do it. My problem is in my Update function I have some actions to perform if there is touch input. and in my OnGUI function I have some buttons to do some action.
When I click my button, the button works. no problem. But my update function finds that there is an touch input. How to solve this?
void Update()
{
if(!isDied){
mm_InputHandler();
if(m_Input.touched){
character.pm_TouchInput(m_Input);
}
}
}
void OnGUI(){
if(GUI.Button(<button code>)){
/*To do code */
}
}
I want the button only to work when I touch the button and not the update function's touch part.
Answer by screenname_taken · Apr 22, 2015 at 09:24 AM
I think you should use the new UI instead. You can have your actions in a single function that is called when you use the button. The button itself recognizes if you touch or use a mouse or a gamepad. So you don't need to have an OnGUI and an Update for different things and have the two fight.