NGUI中EventDelegate时间委托的使用方法
来源:互联网 发布:mac如何安装flash控件 编辑:程序博客网 时间:2024/06/05 02:59
EventDelegate是用于底层进行消息传递和调用的事件委托类型,主要用于对对象事件的监听和处理。
它实际上是一个能够持有对某个方法的引用的类。下面以一个UIButton的单击事件为例,将ClickTheButton
挂载到EventDelegate下面进行回调。源代码如下:
using UnityEngine;using System.Collections;public class ButtonClick : MonoBehaviour { //声明UIButton组件的引用,作为获取组件的引用变量 public UIButton myButton;// Use this for initializationvoid Start () { if (myButton != null) { EventDelegate theButtonClickEvent = new EventDelegate(this, "ClickTheButton"); //Nofity回调本身就是一个事件组,直接注册一个EventDelegate类型的事件 myButton.onClick.Add(theButtonClickEvent); }}// Update is called once per framevoid Update () {} public void ClickTheButton() { Debug.Log("单击myButton按钮!"); }}可以将该代码绑定到任何一个GameObject上面,为方便管理建议绑定到UIRoot下面,然后将一个附有UIButton和
Box Collider组件的物体添加到myButton的引用下面,最后运行脚本就可以在Console视图看到下面的信息提示。
1 0
- NGUI中EventDelegate时间委托的使用方法
- NGUI中 EventDelegate 如何创建一个带参数的函数委托
- NGUI-EventDelegate使用
- Unity中NGUI点击事件委托的应用
- 【Unity3D】【NGUI】如何动态给EventDelegate添加参数
- [unity]NGUI实现背包拖拽+使用EventDelegate回调
- Ngui 委托
- C#中时间和委托的例子
- c#中时间和委托的使用
- iphone 委托的使用方法。
- 委托绑定的使用方法
- ToLua#--lua调用NGUI的事件委托
- ULUA中SPINE动画的切换以及委托的使用方法
- c#委托的基本使用方法
- NGUI中Button的使用
- ngui中scrollview的使用
- NGUI中UIRoot的尺寸
- NGUI中UITextList的使用
- 通俗解释遗传算法及其Matlab实现
- 读书笔记《Effective C++》条款12:复制对象时勿忘其每一个成分
- jedis-2.1.0.jar + spring-data-redis-1.3.0.RELEASE.jar。
- 二叉树的基本操作方式
- 逆向工程核心原理学习笔记(十七):栈帧4:开始执行add()函数&生成栈帧
- NGUI中EventDelegate时间委托的使用方法
- Java compiler level does not match the version of the installed Java project facet.
- 前端进阶——学习感悟
- C、C++ register关键字
- 【python】类内置函数
- 通俗解释matlab之遗传算法程序部分(二)
- 基于spark的精准推荐系统
- spring mvc @ModelAttribute使用
- 事件冒泡的原理?如何禁止事件冒泡 ?