Hi. I have searched a lot of forums, but I can’t find how to detect “touch release” on android. It means, I don’t want to fire a ball when user touch the screen but the ball will be fired when user release the touch. Is it possible? Thanks
It’s late, but this is another solution.
void Update() {
print(TouchRelease());
}
public static bool TouchRelease() {
bool b = false;
for (int i = 0; i < Input.touches.Length; i++) {
b = Input.touches*.phase == TouchPhase.Ended;*
-
if (b)*
-
break;*
- }*
- return b;*
}
It checks whether any of the touches performed during the last frame were released.
if (Input.GetMouseButtonUp(0))
{
//Do somthing;
}
Touch phases are not very reliable.
You can do something like this for single touch.
bool isTouching = false;
Touch info;
Action< Touch > touchUp;
public void Update()
{
if( Input.touchCount == 1 )
{
isTouching = true;
info = Input.touches[0];
}
if( isTouching )
{
if( touchUp != null )
touchUp( info );
isTouching = false;
}
}
if you want to do multi touch, you can check out this:
Blurst Multitouch Handler