当前位置:网站首页>Unity_ Code mode add binding button click event

Unity_ Code mode add binding button click event

2022-04-23 14:46:00 The black dog ran forward

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class MainPanel : MonoBehaviour
{
    private void Awake()
    { 
        // Code mode binding   Click event 
       transform.Find("BtnTargetList").GetComponent<Button>().onClick.AddListener(OnTargetListButtOnClick);
       transform.Find("BtnTargetAdd").GetComponent<Button>().onClick.AddListener(OnTargetAddOnClick);
    }
    
    // Click event 
    private void OnTargetListButtOnClick()
    {
        UiManager.Instance.TargetListPanel.Show();
    }
    
    // Click event 
    private void OnTargetAddOnClick()
    {
        Debug.Log(" banana split ");
    }
}

版权声明
本文为[The black dog ran forward]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231425301806.html