万年素人からHackerへの道

万年素人がHackerになれるまで殴り書きするぜ。

  • ・資産運用おすすめ
    10万円は1000円くらい利益
    資産運用ブログ アセマネ
    • ・寄付お願いします
      YENTEN:YYzNPzdsZWqr5THWAdMrKDj7GT8ietDc2W
      BitZenny:ZfpUbVya8MWQkjjGJMjA7P9pPkqaLnwPWH
      c0ban:8KG95GXdEquNpPW8xJAJf7nn5kbimQ5wj1
      Skycoin:KMqcn7x8REwwzMHPi9fV9fbNwdofYAWKRo

    Coroutineもdelegate Unity C#

    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