- Home /
Long press on EXISTED GUITexture
I have GameObject with GUITexture. I want to handle the long press on it.
All I founded about long press is GUILayout.RepeatButton, but this function wanted to create a new texture on the scene. I thought there is overriding of this function, that get GUITexture component, but there is not. So, maybe there is another way?
Answer by robertbu · Sep 21, 2014 at 01:43 PM
A down press on a GUITexture can be detected by either using OnMouseDown() or by using GUITextrue.HitTest() with Input.GetMouseButtonDown(). Likewise the button up can be detected by OnMouseUp() or by GUITexture.HitTest with Input.GetMouseButtonUp(). Record the time when you get a down event. Subtract that from the current time on the up event. If the time is long enough, you have a long press.