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 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.
Answer by jayant_vishwakarma
Jan 05 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.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user to Unity Answers, check out our FAQ for more information.
Make sure to check out our Knowledge Base for commonly asked Unity questions.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
6 People are following this question.
Android touch position problem
Not getting a response when a touch doesn't move with TKtouchkit
Drag a ball to add force to a ball by touch screen
Mobile controls, gui mouse problem.