- Home /
the differenct between mouse and touch on mobile screen
I used this two codes if (Input.GetTouch (0).phase == TouchPhase.Began) and if (Input.GetMouseButtonUp (0)) on my phone touch screen the things is the Input code for mouse is working as touch as well .Why ist that happening isn't mouse input suppose to react to only mouse input?
Answer by LK84 · Jan 05, 2017 at 02:37 PM
Most of the Input.Mouse.... Methods work as Tap on touchscreen devices which is odd, I agree. I personally wouldn't rely on these. If you want to write a program to work on pc and mobile devices I prefer using platform #define directives, UNITY_ANDROID, UNITY_IOS, UNITY_STANDALONE etc. https://docs.unity3d.com/Manual/PlatformDependentCompilation.html
Answer by jayant_vishwakarma · Jan 05, 2017 at 02:26 PM
if you are getting Input.GetTouch(0).phase == TouchPhase.End while mouse button will get up, actually you are doing both the things at same time, TouchPhase.End will happened when you remove your hand from the screen and mousebuttonup will occure when mouse key is up both the condition can be true at same time but touch phases is suitable for mobile devices and mouse input for desktops, since unity is flexible it offer you to use mouse events in touch devices also.