0
我现在遇到的团结问题:统一委托转换的问题
我尽量让事件侦听器与委托,和我从教程的代码,但我有一个错误,当我尝试添加代理方法转换为其他类方法:“不能隐式转换类型void' to
Metronome.OnTickEvent”。
这里是我的类委托:
public delegate void OnTickEvent();
public event OnTickEvent onTick;
IEnumerator coroutineMetronome() {
if (CustomTimer.manager.timerState) {
for (;;) {
nextTick += delay;
yield return new WaitForSeconds(nextTick - Time.time);
onTick(); // I call the delegate method here
}
}
}
...这是事件接收器类:
protected virtual void Start()
{
manager = this as T;
Metronome.manager.onTick += OnSynchronization(); // Here is the bug line
}
protected void OnSynchronization() {
Debug.Log("coucou");
}
感谢您的帮助!
该死的短版我没看出来。谢谢 – Karz