相关知识点:
Button
疑惑:
收获:
需提高的:
相关代码:
1. 可视化创建及事件绑定
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/*
定义了一个Click的public方法.
在Button下的OnClick中可以选择该方法
*/
public class TestButton : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void Click()
{
Debug.Log("-----点击按钮-----");
}
}
2. 通过直接绑定脚本来绑定事件
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TestButton1 : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Button btn = this.Ge