LuaInterface.LuaFunction.EndPCall C# (CSharp) Method

EndPCall() public method

public EndPCall ( ) : void
return void
        public void EndPCall()
        {
            if (oldTop != -1)
            {
                luaState.EndPCall(oldTop);
                argCount = 0;
                FuncData data = stack.Pop();
                oldTop = data.oldTop;
                stackPos = data.stackPos;
            }
        }

Usage Example

    void Start()
    {
        lua = new LuaState();
        lua.Start();
        lua.DoString(script, "AccessingArray.cs");

        int[] array = { 1, 2, 3, 4, 5};
        func = lua.GetFunction("TestArray");

        func.BeginPCall();
        func.Push(array);
        func.PCall();
        double arg1 = func.CheckNumber();
        string arg2 = func.CheckString();
        bool arg3 = func.CheckBoolean();
        Debugger.Log("return is {0} {1} {2}", arg1, arg2, arg3);
        func.EndPCall();

        //转换一下类型,避免可变参数拆成多个参数传递
        object[] objs = func.Call((object)array);

        if (objs != null)
        {
            Debugger.Log("return is {0} {1} {2}", objs[0], objs[1], objs[2]);
        }

        lua.CheckTop();
    }
All Usage Examples Of LuaInterface.LuaFunction::EndPCall