1、屏幕触摸时间为了防止点UI也会触发游戏层方法事件请不要使用按下鼠标左键执行方法。可以新建个Image带当做可触摸区域(也就是现实中的屏幕)。使用EventTrigger组件挂在Image上,添加Pointer Down(点击图片时也就是触摸按下时)或者Pointer Up(抬起)等事件触发方法来进行游戏层触摸事件。
2、Image的渲染层级要在UI按钮的下面,在同一Canvas上。
3、在想吞噬的UI层上勾选
4、Event脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Event : MonoBehaviour
{
void Start()
{
}
void Update()
{
}
public void onDown()
{
//Debug.Log("onDown");
StateManager.Instance.setEventType(EventType.Down);
}
public void onUp()
{
StateManager.Instance.setEventType(EventType.Up);
}
}