Unity有点击屏幕进行移动操作,通过Input.GetMouseButtonDown(0)。如果点击到了一些UI上面会触发点击屏幕事件。8 x. v6 c% z$ [: m, Y, n6 }& ~$ F2 Z9 ?
引入UnityEngine.EventSystems,用函数判断一下即可: H N, E# R" U0 J& a
: o J( D2 t( Y6 \* o: b
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using UnityEngine.EventSystems;
public class PlayerController : MonoBehaviour
{
private void Update()
{
if (EventSystem.current.IsPointerOverGameObject()) return;
if (Input.GetMouseButtonDown(0))
{
Debug.Log("点击屏幕");
}
}
}