这里使用UGUI系统自带的方法和射线检测的方式,判断是否点击到UI上:
第一种方法:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class Manager : MonoBehaviour
{
public Button quitButton;
// Use this for initialization
void Start()
{
quitButton.onClick.AddListener(OnQuitButtonClick);
}
// Update is called once per frame
void Update()
{
//判断是否点击UI
if (Input.GetMouseButtonDown(0) || (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began))
{
//移动端
if (Application.platform == RuntimePlatform.Android ||
Application.platform == RuntimePlatform.IPhonePlayer)
{
int fingerId =