Unity有点击屏幕进行移动操作,通过Input.GetMouseButtonDown(0)。如果点击到了一些UI上面会触发点击屏幕事件。; R" r7 V2 v; g. y! T; H" ?4 Z
引入UnityEngine.EventSystems,用函数判断一下即可 & d. i+ R3 D( }3 x9 B; w
0 I, L" e) c1 c( H2 C2 a
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("点击屏幕");
}
}
}