- Home /
touch.phase == TouchPhase.Canceled not worked
i m tired to handle and solve issues related to multitouch. i m use maximume 5 touch simultaneously but when two touches are down on two object and i moved my fingures then that both touches fired TouchPhase.Ended event but not fired TouchedPhase.Canceled.
I want to fired TouchPhase.Canceled when i my fingures out of those objects.
if (touch.phase == TouchPhase.Began) { hitObject.GetComponent ().TouchDown (hitObject); }
if (touch.phase == TouchPhase.Ended) { hitObject.GetComponent ().TouchExit (hitObject); }
if (touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary) { hitObject.GetComponent ().TouchStay (hitObject); }
if (touch.phase == TouchPhase.Canceled) { print ("Touched canceled...."); hitObject.GetComponent ().TouchExit (hitObject); }
You need to post your full touch code if you want to get help. Your code is barely readable. You didn't define the value of touch here. Do it so, so we can help.
but i handle more scripts so if i put my whole code then everyone is very confused if anyone have any doubt then tell me .
"...when two touches are down on two object and i moved my fingures then that both touches fired TouchPhase.Ended event but not fired TouchedPhase.Canceled..."
Why would it? A touch is cancelled if "for example, the user puts the device to her face or simultaneously applies more touches than the system can track (the exact number varies with different platforms)". You've simply moved your fingers.
Look,I want to handle 5 touches at a time and i want to handle every events of that 5 touches means all hittedobject's touchdown,touchstay,touchup events how can i handle ?
Answer by screenname_taken · Aug 09, 2014 at 01:03 PM
http://docs.unity3d.com/ScriptReference/Input.GetTouch.html
The touch example in unity's manual show a for loop checking for each touch. Try to change your code into that type perhaps as it'll get around issues with multiple touches.
Look,I want to handle 5 touches at a time and i want to handle every events of that 5 touches means all hittedobject's touchdown,touchstay,touchup events how can i handle ?
With that loop. Each touch will have a different value for the "i" in the loop.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
[HELP] BCE0022: Cannot convert 'UnityEngine.Vector3' to 'UnityEngine.GameObject'. 1 Answer
Hide the ImageTraget in Real world 0 Answers
Texture2d.Readpixel slow down performance while stand-alone exe is minimize 0 Answers
Trying to drag an object with touch using Rigidbody2D.MovePosition 1 Answer