Beispiel #1
0
 public Enumerator(LuaDictTable list)
 {
     state = list.state;
     top   = state.LuaGetTop();
     state.Push(list.table);
     state.LuaPushNil();
 }
Beispiel #2
0
        private void UF_DebugEvent()
        {
            GLuaState lua    = GLuaState.Get(System.IntPtr.Zero);
            int       oldtop = lua.LuaGetTop();

            try{
                lua.LuaGetGlobal("Lua");
                if (lua.LuaIsNil(-1) || !lua.lua_istable(-1))
                {
                    return;
                }
                lua.LuaGetField(-1, "global");
                if (lua.LuaIsNil(-1) || !lua.lua_istable(-1))
                {
                    return;
                }
                lua.LuaGetField(-1, "event");
                if (lua.LuaIsNil(-1) || !lua.lua_istable(-1))
                {
                    return;
                }
                lua.LuaGetField(-1, "debug_event");
                if (lua.LuaIsNil(-1) || !lua.lua_isfunction(-1))
                {
                    return;
                }
                lua.Push(true);
                lua.LuaCall(1, 0);
            }catch (System.Exception ex) {
                Debugger.UF_Exception(ex);
            }
            lua.LuaSetTop(oldtop);
        }
Beispiel #3
0
        private void UF_LuaBaseStart(GLuaState luastate)
        {
            if (luastate != null)
            {
                string toluaroot = LuaRoot;

                string[] luafiles =
                {
                    "Main.lua",

                    "Mathf.lua",        //ToLua/UnityEngine/Mathf.lua
                    "Vector3.lua",      //ToLua/UnityEngine/Vector3.lua
                    "Quaternion.lua",   //ToLua/UnityEngine/Quaternion.lua
                    "Vector2.lua",      //ToLua/UnityEngine/Vector2.lua
                    "Vector4.lua",      //ToLua/UnityEngine/Vector4.lua
                    "Color.lua",        //ToLua/UnityEngine/Color.lua
                    "Ray.lua",          //ToLua/UnityEngine/Ray.lua
                    "Bounds.lua",       //ToLua/UnityEngine/Bounds.lua
                    "RaycastHit.lua",   //ToLua/UnityEngine/RaycastHit.lua
                    "Touch.lua",        //ToLua/UnityEngine/Touch.lua
                    "LayerMask.lua",    //ToLua/UnityEngine/LayerMask.lua
                    "Plane.lua",        //ToLua/UnityEngine/Plane.lua
                    "TypeOf.lua",       //ToLua/System/TypeOf.lua
                    "ValueType.lua",    //ToLua/System/ValueType.lua
                    "BindingFlags.lua", //ToLua/System/BindingFlags.lua
                };

                int top = m_Luastate.LuaGetTop();
                for (int k = 0; k < luafiles.Length; k++)
                {
                    var assetinfo = AssetDataBases.UF_GetAssetInfo(luafiles[k]);
                    if (assetinfo == default(AssetDataBases.AssetFileInfo))
                    {
                        throw new LuaException(string.Format("Can not get lua file[{0}] in AssetDataBase,Load file failed!", luafiles[k]), LuaException.GetLastError());
                    }
                    if (!UF_DoFile(m_Luastate.LuaGetL(), assetinfo.path, Path.GetFileNameWithoutExtension(assetinfo.name)))
                    {
                        string err = m_Luastate.LuaToString(-1);
                        m_Luastate.LuaSetTop(top);
                        throw new LuaException(err, LuaException.GetLastError());
                    }
                }
                m_Luastate.LuaSetTop(top);

                //打开基础库
                LuaUnityLibs.OpenLuaLibs(luastate.LuaGetL());

                luastate.Start();
            }
        }
Beispiel #4
0
        private string UF_GetLuaGInfo()
        {
            GLuaState lua    = GLuaState.Get(System.IntPtr.Zero);
            int       oldtop = lua.LuaGetTop();

            lua.LuaGetGlobal("TraceGlobal");
            string info = string.Empty;

            if (!lua.LuaIsNil(-1) && lua.lua_isfunction(-1))
            {
                lua.LuaCall(0, 1);
                info = lua.LuaToString(-1);
            }
            lua.LuaSetTop(oldtop);
            return(info);
        }
Beispiel #5
0
 public Enumerator(LuaArrayTable list)
 {
     state = list.state;
     top   = state.LuaGetTop();
     state.Push(list.table);
 }