【Unity3D】【NGUI】怎样动态给EventDelegate加入參数
2016-03-15 16:47
555 查看
NGUI讨论群:333417608
NGUI版本号:3.6.8
注意:參数必须是公共成员变量。不能是栈上的、或者私有的(就是暂时在函数里面定义的或者是函数的參数都不行)
NGUI版本号:3.6.8
注意:參数必须是公共成员变量。不能是栈上的、或者私有的(就是暂时在函数里面定义的或者是函数的參数都不行)
using UnityEngine; using System.Collections; public class SZEventDelegateParams : MonoBehaviour { public int param = 2; void Start() { // 创建新的delegate,最后调用此(this)脚本的Finished函数。当然this能够换成别的脚本。这里为了方便 EventDelegate eventDelegate = new EventDelegate(this, "Finished"); // 把第一个參数设置为此(this)脚本的param变量。当然this能够换成别的脚本,这里为了方便 eventDelegate.parameters[0] = new EventDelegate.Parameter(this, "param"); UIPlayTween uipt = this.GetComponent<UIPlayTween>(); uipt.onFinished.Add(eventDelegate); uipt.Play(true); } // PlayTween 结束后。会调用到这里,打印对应的值 void Finished(int p) { Debug.Log(p.ToString()); } }
相关文章推荐
- Unity3d Json解析库
- [UnityUI]UGUI新手引导
- [Unity插件]DOTween(2)
- Unity AssetBundle爬坑手记
- 贝塞尔曲线制作跳跃轨迹
- 推荐 git community book 中文版
- Unity入门之UGUI中Image的属性
- Unity3D游戏开发之使用Unity3D开发2D游戏(二)(2DTookit插件亲测)
- Unity学习之实现拖拽功能
- unity terrain export to obj
- unity3d上用vuforia开发AR
- Unity制作人物头像小图标和小地图
- Unity3D之MeleeWeaponTrail武器轨迹插件的使用
- Unity Shaders and Effects Cookbook (1-1) 基本的表面着色器 (Surface Shader)
- iTween基础之CameraFade(摄像机淡入淡出)
- unity的input鼠标
- unity AssetBundles
- Unity3d开发(九) 动画模型资源导入预处理
- Unity实例-坦克大战
- 自己主动生成材质Material(Unity3D开发之十九)