在创建了一个Button后,结构如图:
先仔细观察一下Button的Inspector视图:
发现其中竟然有一个叫Button的脚本组件.
新建脚本,代码如下,并将该脚本绑定给Canvas组件:
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UnityEngine;
public class btn1 : MonoBehaviour
{
// Start is called before the first frame update
public Button btn