zoukankan      html  css  js  c++  java
  • 【Ngui 学习系列之一:简单组件的操作】

    一、Button
    unity edit:
    Sprite作为父对象和背景
    -- Collider
    -- Button script
    Label 作为子对象和显示文字
    代码:
    private UIButton Button;
    void Start ()
    {
    EventDelegate btnOnClickEventDelegate = new EventDelegate(this,"ButtonClick");
    Button = GameObject.Find("Button").GetComponent<UIButton>();
    Button.onClick.Add(btnOnClickEventDelegate);
    }

    private void ButtonClick()
    {
    Debug.Log("点击了Button");
    }

    二、Popup List 下拉
    unity edit:
    Sprite作为父对象和背景
    -- Collider
    -- Button script
    -- Popup List script(重要)
    options: 下拉选择的内容
    On Value Change:值改变时的操作
    notify:子对象的Label
    Method:UILabel->SetCurrentSelection
    代码:
    private UIPopupList PopupList;
    private UILabel PopupListLabel;

    void Start ()
    {
    EventDelegate popupListChangeDelegate = new EventDelegate(this, "PopupListChange");

    PopupList = GameObject.Find("Popup List").GetComponent<UIPopupList>();
    PopupListLabel = PopupList.GetComponent<Transform>().FindChild("Label").GetComponent<UILabel>();

    PopupList.onChange.Add(popupListChangeDelegate);
    }

    private void PopupListChange()
    {
    Debug.Log(PopupListLabel.text);
    }

    三、Checkbox 单选框
    unity edit:
    widget作为父对象
    -- Collider
    -- Button script
    -- Toggle script(重要)
    State Transition
    sprite: 钩子的sprite对象
    Sprite 作为框的背景
    -- Sprite 作为上一个sprite的子对象,显示钩子
    Label 文字说明
    代码:
    private UIToggle Toggle;
    void Start ()
    {
    EventDelegate toggleChangeDelegate = new EventDelegate(this,"ToggleChange");

    Toggle = GameObject.Find("Checkbox").GetComponent<UIToggle>();
    Toggle.onChange.Add(toggleChangeDelegate);
    }

    private void ToggleChange()
    {
    Debug.Log(Toggle.value.ToString());
    }











  • 相关阅读:
    python 多个变量赋值
    python标准数据类型
    Python 变量类型
    H3C 扩展ACL与基于时间的ACL
    H3C BGP-filter-policy
    H3C 标准ACL
    H3C BGP实验集合
    H3C IS-IS实验大集合(ipv6)
    H3C ISIS实验大集合(IPv4)
    JS 封装一个显示时间的函数
  • 原文地址:https://www.cnblogs.com/yexiaopeng/p/6137789.html
Copyright © 2011-2022 走看看