在Canvas下新建UI-Panel,依次添加Button Image Text为子节点。
Panel铺满需要识别点击的区域
在Panel上挂载Button组件
取消Image的Image组件和Text的Text组件中Raycast Target的勾选
编写脚本,挂载在Panel上
using UnityEngine;
using UnityEngine.UI;
public class Window : MonoBehaviour
{
private void Start()
{
this.GetComponent<Button>().onClick.AddListener(() =>
{
this.gameObject.SetActive(false);
});
}
}
就完成了
标签:Text,Image,点击,关闭,组件,using,弹窗,Panel From: https://www.cnblogs.com/TopGameDesigner/p/17417503.html