using System;
using UnityEngine;


public class TestPanel : MonoBehaviour
{

    private UIToggle tog;
    private UIButton but;
    void Awake()
    {
        tog = transform.FindChild("Toggle").GetComponent<UIToggle>();
        but = transform.FindChild("Button").GetComponent<UIButton>();
        EventDelegate.Add(tog.onChange, delegate ()
        {
            OnToggleClick(tog.value);
        });
        EventDelegate.Add(but.onClick, delegate ()
        {
            OnButtonClick(but.gameObject);
        });
    }


    public void OnToggleClick(bool isON)
    {
        if (isON)
            Debug.LogError("开");
        else
            Debug.LogError("关");
    }

    public void OnButtonClick(GameObject but)
    {
        Debug.LogError(but.name);
    }



}

untiy3d NGUI为UIButton和UIToggle脚本绑定方法
图片.png

相关文章:

  • 2021-08-09
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2021-04-22
  • 2021-11-10
  • 2021-09-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2021-04-10
  • 2021-12-29
相关资源
相似解决方案