Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
-1
Question by yters · Oct 30, 2011 at 08:06 AM · iphonemouseclicktap

Unity iPhone does not detect mouse clicks as taps

I am using Unity iPhone version 1.5.1f2. I am trying to detect taps on 3D objects using rays. On the simulator I am using mouseclicks as taps. However, Unity does not catch the mouseclicks. Here is the code I am using, adapted from code I found online:

 using UnityEngine;
 using System.Collections;
 
 public class multitouch_response : MonoBehaviour
 {
 
     // Use this for initialization
     void Start ()
     {
         
     }
     
     public int tc = 0;
     
     void Update () {
         // Code for OnMouseDown in the iPhone. Unquote to test.
         RaycastHit hit = new RaycastHit();
         Debug.Log("touchCount " + iPhoneInput.touchCount + " taps " + tc);
 
         for (int i = 0; i < iPhoneInput.touchCount; ++i) {
             Debug.Log("Touches");
 
             if (iPhoneInput.GetTouch(i).phase.Equals(iPhoneTouchPhase.Began)) {
                 Debug.Log("Touch began");
 
                 // Construct a ray from the current touch coordinates
                 Ray ray = Camera.main.ScreenPointToRay(iPhoneInput.GetTouch(i).position);
 
                 if (Physics.Raycast(ray, out hit)) {
                     hit.transform.gameObject.SendMessage("OnMouseDown");
                 }
             }
            }
     }
 
     public void OnMouseDown () {
         tc++;
     }
 }

The only debug information produced is:

touchCount 0 taps 0

So this means the code is not picking up any touches.

Can someone help explain what I'm doing wrong here?

Much appreciated, Eric

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ina · Oct 30, 2011 at 08:20 AM 0
Share

you might want to use the Input.Touches http://unity3d.com/support/documentation/ScriptReference/Input-touches.html ins$$anonymous$$d of the deprecated iPhoneInput http://unity3d.com/support/documentation/ScriptReference/Touch.html

avatar image yters · Oct 30, 2011 at 01:04 PM 0
Share

@Ina: $$anonymous$$y unity version doesn't have mobile devices in Input. It's an old version, and right now I'm not keen on paying the upgrade cost to fix this one problem.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by GoSuNeem · Oct 30, 2011 at 02:31 PM

I have not used a older version of unity so I can't give a definate answer but in current version, mouse events are turned off when you are on Iphone/iPad mode. If you really want to use mousedowns for testing, you should use input.GetMouseButtonDown(0) or input.GetButtonDown() in update.

http://unity3d.com/support/documentation/ScriptReference/Input.GetMouseButtonDown.html

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image yters · Oct 30, 2011 at 11:55 PM 0
Share

@GoSuNeem: Thanks for the response. That makes sense. I had thought Unity would consider mouseclicks to be taps, but I guess not.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Making a GUI Texture tappable on iPhone 4 Answers

Touch.deltaTime confusion 0 Answers

Help with code logic iPhone Touch FPS 0 Answers

Tapping an object in an Android game 0 Answers

iphone: how to tap and make an object delete? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges