Base class for custom yield instructions to suspend coroutines.

Inheritance: IEnumerator
コード例 #1
0
    static void CustomYieldInstruction_Current(JSVCall vc)
    {
        UnityEngine.CustomYieldInstruction _this = (UnityEngine.CustomYieldInstruction)vc.csObj;
        var result = _this.Current;

        JSMgr.datax.setWhatever((int)JSApi.SetType.Rval, result);
    }
 static public int get_keepWaiting(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.CustomYieldInstruction self = (UnityEngine.CustomYieldInstruction)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.keepWaiting);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
コード例 #3
0
////////////////////// CustomYieldInstruction ///////////////////////////////////////
// constructors

// fields

// properties
    static void CustomYieldInstruction_keepWaiting(JSVCall vc)
    {
        UnityEngine.CustomYieldInstruction _this = (UnityEngine.CustomYieldInstruction)vc.csObj;
        var result = _this.keepWaiting;

        JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(result));
    }
 static public int get_Current(IntPtr l)
 {
     try {
         UnityEngine.CustomYieldInstruction self = (UnityEngine.CustomYieldInstruction)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.Current);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int Reset(IntPtr l)
 {
     try {
         UnityEngine.CustomYieldInstruction self = (UnityEngine.CustomYieldInstruction)checkSelf(l);
         self.Reset();
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int MoveNext(IntPtr l)
 {
     try {
         UnityEngine.CustomYieldInstruction self = (UnityEngine.CustomYieldInstruction)checkSelf(l);
         var ret = self.MoveNext();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
コード例 #7
0
 static int Reset(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.CustomYieldInstruction obj = (UnityEngine.CustomYieldInstruction)ToLua.CheckObject(L, 1, typeof(UnityEngine.CustomYieldInstruction));
         obj.Reset();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #8
0
 static int MoveNext(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.CustomYieldInstruction obj = (UnityEngine.CustomYieldInstruction)ToLua.CheckObject(L, 1, typeof(UnityEngine.CustomYieldInstruction));
         bool o = obj.MoveNext();
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #9
0
    static int get_Current(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.CustomYieldInstruction obj = (UnityEngine.CustomYieldInstruction)o;
            object ret = obj.Current;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index Current on a nil value" : e.Message));
        }
    }
コード例 #10
0
    static int get_keepWaiting(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.CustomYieldInstruction obj = (UnityEngine.CustomYieldInstruction)o;
            bool ret = obj.keepWaiting;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index keepWaiting on a nil value" : e.Message));
        }
    }
コード例 #11
0
        public void Update()
        {
            try
            {
                if (!visibilityHandler.IsVisible)
                {
                    return;
                }

                if (!startCalled)
                {
                    startCalled = true;

                    if (startMethod != null)
                    {
                        startMethod.Invoke(referencedNode, null);
                    }
                    else if (startMethodCR != null)
                    {
                        StartCoroutine((IEnumerator)startMethodCR.Invoke(referencedNode, null));
                    }
                }

                if (updateMethod != null)
                {
                    updateMethod.Invoke(referencedNode, null);
                }

                for (int i = 0; i < coroutines.Count; i++)
                {
                    CustomYieldInstruction yielder = coroutines[i].Current as CustomYieldInstruction;
                    bool yielded = yielder != null && yielder.MoveNext();

                    if (!yielded && !coroutines[i].MoveNext())
                    {
                        coroutines.RemoveAt(i);
                        i--;
                    }
                }
            }
            catch (System.Exception e)
            {
                Debug.Log(e.Message + "\n\n" + e.StackTrace);
            }
        }