1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
uipt.onFinished.Add(eventDelegate);
uipt.Play(true);
}
// PlayTween 结束后,会调用到这里,打印相应的值
void Finished(int p)
{
Debug.Log(p.ToString());
}
}