C#でできるか実験した
URL:http://forum.unity3d.com/threads/49221-Delegates-and-Co-routines-and-yield-WaitforSeconds
実際にはこのように書いた。
using UnityEngine; using System.Collections; delegate void NormalDelegate(int a); delegate IEnumerator WaitFunction(int a); public class DelegateCS : MonoBehaviour { void Awake() { } void Start() { NormalDelegate normal = Normal; WaitFunction wait = Wait; normal(1); StartCoroutine(wait(2)); // StartCoroutineを付けないと、エラーにはならないがそもそも動かなかった // wait(2); } static void Normal(int n) { Debug.Log (n.ToString() + " called"); } static IEnumerator Wait(int n) { yield return new WaitForSeconds(2.0F); Debug.Log (n.ToString() + " called"); } }
NormalDelegateはふつうのDelegateで
WaitFunctionは今回実験したCoroutineに対応したDelegate