コード例 #1
0
    private static int AddRepeatingTimer(IntPtr L)
    {
        int result;

        try
        {
            ToLua.CheckArgsCount(L, 6);
            TimerManager            timerManager = (TimerManager)ToLua.CheckObject(L, 1, typeof(TimerManager));
            GameObject              go           = (GameObject)ToLua.CheckUnityObject(L, 2, typeof(GameObject));
            string                  timerName    = ToLua.CheckString(L, 3);
            float                   delay        = (float)LuaDLL.luaL_checknumber(L, 4);
            float                   interval     = (float)LuaDLL.luaL_checknumber(L, 5);
            LuaTypes                luaTypes     = LuaDLL.lua_type(L, 6);
            TimerManager.UpdateFunc func;
            if (luaTypes != LuaTypes.LUA_TFUNCTION)
            {
                func = (TimerManager.UpdateFunc)ToLua.CheckObject(L, 6, typeof(TimerManager.UpdateFunc));
            }
            else
            {
                LuaFunction func2 = ToLua.ToLuaFunction(L, 6);
                func = (DelegateFactory.CreateDelegate(typeof(TimerManager.UpdateFunc), func2) as TimerManager.UpdateFunc);
            }
            timerManager.AddRepeatingTimer(go, timerName, delay, interval, func);
            result = 0;
        }
        catch (Exception e)
        {
            result = LuaDLL.toluaL_exception(L, e, null);
        }
        return(result);
    }