using UnityEngine;
using System.Collections;
public class StartBtnCsScript : MonoBehaviour
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.touchCount > 0)//如果存在Touch事件
{
if (Input.GetTouch(0).phase == TouchPhase.Began)//相当于TouchDown
{
Debug.Log("[Shark]Touch Began");
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);//获得触点坐标,并生成一个射线源
RaycastHit hit;
if (Physics.Raycast(ray, out hit, 5000))//从射线源发出一条长为5000的射线
{
Debug.Log("[Shark]Ray cast");
if (hit.collider.gameObject.name == "StartMenu")//判断射线穿过的对象中是否有你想要的那个对象
{
Debug.Log("[Shark]Find Object");//这里就可以处理点击事件
rotationF();
}
}
}
}
}
void rotationF()
{
transform.Rotate(0, 30, 0);
}
}
在Unity3D中实现Touch,细节需要我们手动实现using UnityEngine;using System.Collections;public class StartBtnCsScript : MonoBehaviour{ // Use this for initialization void Start() { } // Upda