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("===hit.transform.gameObject.name==" + hit.transform.gameObject.name);