【Unity3D自学记录】Unity3D代理委托模式
2014-05-29 09:56
295 查看
using UnityEngine; using System.Collections; public class DJH_Delegate : MonoBehaviour { public delegate void Delegate1(); public Delegate1 OutTest1; public delegate void Delegate2(int index); public Delegate2 OutTest2; int index = 12345; void Start() { OutTest1 = DebugLog1; OutTest2 = DebugLog2; } void OnGUI() { //开始按钮 if (GUI.Button(new Rect(0, 10, 100, 30), "Button1")) { if (OutTest1 != null)//无参数 { DebugLog1(); } } if (GUI.Button(new Rect(0, 60, 100, 30), "Button2")) { if (OutTest2 != null)//有参数 { DebugLog2(index); } } } void DebugLog1() { Debug.Log("Button1"); } void DebugLog2(int index) { Debug.Log("Button2参数:" + index); } }
相关文章推荐
- 【Unity3D自学记录】UnityWebPlayer网页全屏模式代码
- Unity3D 利用C#实现简单的代理模式Delegate(委托)
- 六 设计模式之代理模式(或称委托模式)
- java的委托机制 .....代理模式
- 【Unity3D自学记录】判断物体是否在镜头内
- 在C#中使用代理(即委托)的方式触发事件(观察者模式)
- 【Unity3D自学记录】遮挡剔除的简单教程
- 2009-04-27读书记录:《大话设计模式》第七章——代理模式
- 【Unity3D自学记录】批量更换预设物体。
- 【Unity3D自学记录】遍历父物体下所有子物体
- 【Unity3D自学记录】获取WWW下载的进度
- 【Unity3D自学记录】关于Animation(动画)倒着播放方法
- iOS的代理(委托设计模式)和分类
- 【Unity3D自学记录】AssetBundles的使用
- 【Objective-C】OC中代理(委托)设计模式
- 【Unity3D自学记录】插件之KGFMapSystem,小地图快速创建
- java的委托机制 .....代理模式
- 【Objective-C】OC中代理(委托)设计模式
- 【Unity3D自学记录】NGUI之编写跟随鼠标代码
- 【Unity3D自学记录】NGUI之ButtonMessage传参