コード例 #1
0
    public static Ev.CoroutineUnit StartCoroutineEx(this GameObject obj, IEnumerator fiber, System.Action f = null, System.Action c = null)
    {
        if (fiber == null)
        {
            return(null);
        }

        Ev.CoroutineUnit corutineUnit = obj.AddComponent <Ev.CoroutineUnit>() as Ev.CoroutineUnit;
        corutineUnit.Initialize(fiber, f, c);

        return(corutineUnit);
    }
コード例 #2
0
    public static Ev.CoroutineUnit StartCoroutineEx(this MonoBehaviour behaviour, string func, object[] param, System.Action finish = null, System.Action cancel = null)
    {
        if (null == behaviour)
        {
            return(null);
        }

        //Debug.Log("StartCoroutineEx " + behaviour.gameObject.name + " + " + func );

        if (string.IsNullOrEmpty(func))
        {
            NGUIDebug.Log("string.IsNullOrEmpty(func)");
            Debug.LogError("string.IsNullOrEmpty(func)");
            return(null);
        }

        MethodInfo m = behaviour.GetType().GetMethod(func, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);

        if (null == m)
        {
            NGUIDebug.Log("null == m " + func);
            Debug.LogError("null == m " + func);
            return(null);
        }

        if (m.ReturnType == typeof(IEnumerator))
        {
            IEnumerator fiber = m.Invoke(behaviour, param) as IEnumerator;

            if (null == fiber)
            {
                Debug.LogError("null == fiber " + behaviour.gameObject.name + " + " + func);
                return(null);
            }

            Ev.CoroutineUnit corutineUnit = behaviour.gameObject.AddComponent <Ev.CoroutineUnit>() as Ev.CoroutineUnit;

            if (null == corutineUnit)
            {
                Debug.LogError("null == corutineUnit " + behaviour.gameObject.name + " + " + func);
                return(null);
            }

            corutineUnit.Initialize(fiber, func, finish, cancel);

            return(corutineUnit);
        }

        //Debug.Log("Not Found Coroutine "  + behaviour.gameObject.name + " + " + func );

        return(null);
    }