using System;using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;public class MainPanel : MonoBehaviour{private void Awake(){ //代码方式绑定 点击事件transform.Find("BtnTargetList").GetComponent<Button>().onClick.AddListener(OnTargetListButtOnClick);transform.Find("BtnTargetAdd").GetComponent<Button>().onClick.AddListener(OnTargetAddOnClick);}//点击事件private void OnTargetListButtOnClick(){UiManager.Instance.TargetListPanel.Show();}//点击事件private void OnTargetAddOnClick(){Debug.Log("香蕉船🍌");}}
如果觉得《Unity_代码方式添加绑定按钮点击事件》对你有帮助,请点赞、收藏,并留下你的观点哦!