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