How to read the tapped object name

Ask for help and post bugs.

How to read the tapped object name

Postby madhu » Tue Sep 13, 2016 3:53 pm


In my Unity app I am loading a 3D model as a assetbundle and I can perform rotation, zoom etc on this model using Touchscript events.
Now I want to detect when I touch on a specific area in the model, the name of the game object layer which I touched or clicked. I am trying to do this inside the TapGesture event and the event get triggered when I tap somewhere. But not sure how to read the layer/object name where I tapped. Can you please provide a sample code on how to do that. I am using Touch script 6.10 and Unity 5.2.1
I tried this and it's always returing the name of a plane which I have added inside the MainCamera. All the Touch script events are added to this plane. It doesn't detect the actual object but this plane.
Code: Select all
Ray ray = Camera.main.ScreenPointToRay(gesture.ScreenPosition);
            RaycastHit hit = new RaycastHit();
            if (Physics.Raycast(ray, out hit, Mathf.Infinity))
                Debug.Log("" +;

Posts: 15
Joined: Tue Oct 20, 2015 4:14 pm

Return to Help and Bugs

Who is online

Users browsing this forum: Google [Bot] and 8 guests