Exemplo n.º 1
0
    /// <summary>
    /// Inits the S lua.
    /// </summary>
    /// <returns><c>true</c>, if S lua was inited, <c>false</c> otherwise.</returns>
    /// <param name="progress">Progress.</param>
    public static bool              InitSLua(System.Action <int> progress)
    {
        XBytecodeFilePicker.InitPicker();

        luaServer = new LuaSvr();

        platformPath = GetPlatformBytecodeFloder();
        if (!string.IsNullOrEmpty(platformPath))
        {
            LuaSvr.mainState.loaderDelegate = LoadScript;
        }

        Debug.LogFormat("BytecodeFloder : {0}", platformPath);

        luaServer.init(progress, () => {
                        #if !RELEASE
            LuaSvr.mainState["_DEBUG"] = true;
                        #endif

                        #if UNITY_EDITOR
            LuaSvr.mainState["_EDITOR"] = true;
                        #endif

                        #if UNITY_ANDROID
            LuaSvr.mainState["_ANDROID"] = true;
                        #endif

                        #if UNITY_IPHONE
            luaServer.luaState["_IPHONE"] = true;
                        #endif

                        #if _LANGUAGE_CN
            LuaSvr.mainState["_LANGUAGE_CN"] = true;
                        #endif

                        #if _LANGUAGE_EN
            LuaSvr.mainState["_LANGUAGE_EN"] = true;
                        #endif

                        #if _LOCAL_SERVER
            LuaSvr.mainState["_LOCAL_SERVER"] = true;
                        #endif

            var success = luaServer.start("main");
            if (success == null || (bool)success != true)
            {
                Debug.LogError("Lua main intialize failed.");
            }
        }, LuaSvrFlag.LSF_BASIC | LuaSvrFlag.LSF_EXTLIB
                        #if !RELEASE && LUA_DEBUG
                       | LuaSvrFlag.LSF_DEBUG
                        #endif
                       );

        return(true);
    }