- Home /
GuiTexture touch button problem
I have this code:
void Update(){
if(Input.touchCount > 0){
if (Input.GetTouch(0).phase==TouchPhase.Began &&
GuiTexture.HitTest(Input.GetTouch(0).position)){
GuiTexture.RescaleDown();//Rescale Texture Down
}
if (Input.GetTouch(0).phase==TouchPhase.Ended){
GuiTexture.RescaleUp();//Rescale Texture Up
if (GuiTexture.HitTest(Input.GetTouch(0).position)){
Application.Quit();
}
}
}
}
In Samsung galaxy S is running correctly.
In nexus 7 -> When I press the texture is RescaleDown and RescaleUp a few times and then closes the application, if I do it with another texture that does not close the application, texture is resizing 1 time down and 1 up correctly.
Help¿?
I want to say that they are the effects of calling Application.Quit. You are calling rescale up on the same frame you are quiting....so as the game if free up stuff and closing down but is still trying to redraw your guitexture. I suggest moving the application.quit to a coroutine and wait, say .25 seconds.
.... if (GuiTexture.HitTest(Input.GetTouch(0).position)){
StartCoroutine(ExitG());
}
....
IEnumerator ExitG(){
yield return new WaitForSeconds(0.1f);
Application.Quit();
}
Yes this work correctly, THAN$$anonymous$$S!!
Your answer
Follow this Question
Related Questions
Input.getTouch() vs checking if button is clicked 1 Answer
Help with touch input for iOS please! 1 Answer
How to replace input axis keyboard button with touch button? 3 Answers
Drag and Drop button on Mobile (Messenger style) 0 Answers
UI button touch input problem when UI is SetActive during game play 1 Answer