Пример #1
0
 void StartLuaScript()
 {
     // Make sure that we got script file before start
     if (luaScript != null)
     {
         // Initializing
         svr = new LuaSvr();
         svr.init(null, () =>
         {
             object obj;
             // Reading lua scripts
             if (svr.luaState.doBuffer(luaScript.bytes, "Here can be any name but should unique", out obj))
             {
                 // Calling main function from lua script
                 LuaFunction func = (LuaFunction)svr.luaState["main"];
                 if (func != null)
                 {
                     self   = (LuaTable)func.call();
                     update = (LuaFunction)self["update"];
                 }
                 else
                 {
                     Debug.LogError("No main function");
                 }
             }
             else
             {
                 Debug.LogError("Can not read scripts");
             }
         });
     }
 }
Пример #2
0
    void Start()
    {
        Application.targetFrameRate = LGameConfig.DEFAULT_FRAME_RATE;

        if (_l == null)
        {
#if UNITY_5
            Application.logMessageReceived += this.log;
#else
            Application.RegisterLogCallback(this.log);
#endif
            if (LGameConfig.GetInstance().isDebug)
            {
                LuaState.loaderDelegate = loadFileWithSuffix;
            }
            else
            {
                LuaState.loaderDelegate = loadLuaWithAb;
            }
            _l = new LuaSvr();
            _l.init(tick, complete);
        }
        else
        {
            complete();
        }
    }
Пример #3
0
        public void StartLuaSvr(Action <bool> onComplete)
        {
            string    initModulePath  = GetModulePath(m_luaInitModuleName);
            TextAsset initModuleAsset = null;

            initModuleAsset = ResourceManager.Instance.LoadAsset <TextAsset>(initModulePath);

            if (initModuleAsset == null)
            {
                Debug.LogError("StartLuaSvr fail load initModuleAsset fail");
                onComplete(false);
            }

            // 构造lua state 环境
            m_luaSvr = new LuaSvr();

            // 设置lua模块加载器
            LuaSvr.mainState.loaderDelegate = LuaLoader;

            // 初始化lua环境
            m_luaSvr.init(null, () =>
            {
                // 加载初始化模块
                if (!string.IsNullOrEmpty(m_luaInitModuleName))
                {
                    m_luaSvr.start(m_luaInitModuleName);
                }
            });
            onComplete(true);
        }
Пример #4
0
    // Use this for initialization
    void Start()
    {
        l = new LuaSvr();
        l.init(null, () =>
        {
            l.start("valuetype");
        });

        using (LuaState newState = new LuaState())
        {
            LuaTable table = new LuaTable(newState);

            Vector2 v2  = new Vector2(1, 2);
            Vector3 v3  = new Vector3(1, 2, 3);
            Vector4 v4  = new Vector4(1, 2, 3, 4);
            Color   col = new Color(.1f, .2f, .3f);
            Foo     foo = new Foo();

            table["v2"]  = v2;
            table["v3"]  = v3;
            table["v4"]  = v4;
            table["col"] = col;
            table["foo"] = foo;

            Assert.IsTrue((Vector2)table["v2"] == v2);
            Assert.IsTrue((Vector3)table["v3"] == v3);
            Assert.IsTrue((Vector4)table["v4"] == v4);
            Assert.IsTrue((Color)table["col"] == col);
            Assert.IsTrue(table["foo"] == foo);
        }
    }
Пример #5
0
 void Start()
 {
     luaSvr = new LuaSvr();
     luaSvr.init(null, () => {
         luaSvr.start("useLua");
     }, LuaSvrFlag.LSF_DEBUG);
 }
Пример #6
0
 // Use this for initialization
 void Start()
 {
     l = new LuaSvr();
     l.init(null, () => {
         l.start("delegate");
     });
 }
Пример #7
0
    public void Startup()
    {
#if !UNITY_EDITOR
        LuaFileCache.Instance.InitLuaBytecode();
#endif
        luaSvr.init(ScriptLoadTick, ScriptLoadCompleted, LuaSvrFlag.LSF_BASIC);
    }
Пример #8
0
 // Use this for initialization
 void Start()
 {
     l = new LuaSvr();
     l.init(null, () =>
     {
         l.start("LuaTest");
     });
 }
Пример #9
0
 // Use this for initialization
 void Start()
 {
     l = new LuaSvr();
     l.init(null, () =>
     {
         l.start("varobj");
     });
 }
Пример #10
0
 // Use this for initialization
 void Start()
 {
     l = new LuaSvr();
     l.init(null, () =>
     {
         l.start("valuetype");
     });
 }
Пример #11
0
 // Use this for initialization
 void Start()
 {
     luaSvr = new LuaSvr();
     luaSvr.init(null, () =>
     {
         self = (LuaTable)luaSvr.start("startGame");
     });
 }
Пример #12
0
    public void Init()
    {
        LuaState.loaderDelegate += LoaderDelegate;

        l = new LuaSvr();
        l.init(null, Complete, LuaSvrFlag.LSF_EXTLIB);
        DontDestroyOnLoad(this);
    }
Пример #13
0
        private LuaModule()
        {
#if UNITY_EDITOR
            UnityEngine.Debug.Log("Consturct LuaModule...");
#endif
            _luaSvr = new LuaSvr();
            _luaSvr.init(progress => { }, () => { });
        }
Пример #14
0
 void Start()
 {
     svr = new LuaSvr();
     svr.init(null, () =>
     {
         self = (LuaTable)svr.start("skynet/main");
     }, LuaSvrFlag.LSF_EXTLIB);
 }
Пример #15
0
 void Start()
 {
     c = this;
     l = new LuaSvr();
     l.init(null, () =>
     {
         l.start("BindCSharp");
     });
 }
Пример #16
0
 void Start()
 {
     c = this;
     l = new LuaSvr();
     l.init(null, () =>
     {
         l.start("custom");
     });
 }
Пример #17
0
 void Start()
 {
     luaSvr = new LuaSvr();
     LuaSvr.mainState.loaderDelegate += LuaLoader;
     luaSvr.init(null, () =>
     {
         luaSvr.start("CreatePrefab.Lua");
     });
 }
Пример #18
0
 void Start()
 {
     luaSvr = new LuaSvr();
     LuaSvr.mainState.loaderDelegate += LuaLoader;
     luaSvr.init(null, () =>
     {
         luaSvr.start("MyPackage.Lua");
     });
 }
Пример #19
0
        /////////////////////////////////////////////////////////

        /// <summary>
        /// 初始化
        /// </summary>
        public void initialize()
        {
            _luaSvr = new LuaSvr();
#if UNITY_EDITOR
            _luaSvr.init(null, svrInitComplete, LuaSvrFlag.LSF_DEBUG);
            //设置脚本加载器
            LuaState.loaderDelegate = scriptLoaderEditor;
            if (AssetManager.getInstance().IsFirstUseStreamingAssets)
            {
                InitLuaData();
            }
#else
            _luaSvr.init(null, svrInitComplete, LuaSvrFlag.LSF_BASIC);
            //设置脚本加载器
            LuaState.loaderDelegate = scriptLoaderRelease;
            InitLuaData();
#endif
        }
Пример #20
0
 void Start()
 {
     c = this;
     l = new LuaSvr();
     l.init(null, () =>
     {
         l.start("custom");
     });
 }
Пример #21
0
 void Start()
 {
     svr = new LuaSvr();
     svr.init(null, () =>
     {
         self   = (LuaTable)svr.start("circle/circle");
         update = (LuaFunction)self["update"];
     });
 }
Пример #22
0
 void Start()
 {
     luaSvr = new LuaSvr();
     LuaSvr.mainState.loaderDelegate += LuaLoader;
     luaSvr.init(null, () =>
     {
         luaSvr.start("UseCSharpClass.Lua");
     });
 }
Пример #23
0
 public void ResetStatus()
 {
     svr = new LuaSvr();
     svr.init(null, () =>
     {
         CallScript("Main");
         save = LuaSvr.mainState.getFunction("save");
     });
 }
 // Use this for initialization
 void Start()
 {
     luaSvr = new LuaSvr();
     luaSvr.init(null, () =>
     {
         self = (LuaTable)luaSvr.start("main");
         //selfUpdate = (LuaFunction)self["update"];
     });
 }
Пример #25
0
    private void Awake()
    {
        LuaSvr svr = new LuaSvr();

        svr.init(null, () =>
        {
            svr.start("06_RequireImport/06_RequireImport");
        });
    }
Пример #26
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);
    }
Пример #27
0
 void Start()
 {
     svr = new LuaSvr();
     svr.init(null, () =>
     {
         self   = (LuaTable)svr.start("circle/circles");
         update = (LuaFunction)self["update"];
         ud     = update.cast <UpdateDelegate>();
     });
 }
Пример #28
0
    void Start()
    {
#if UNITY_5
        Application.logMessageReceived += this.log;
#else
        Application.RegisterLogCallback(this.log);
#endif
        _l = new LuaSvr();
        _l.init(tick, complete, LuaSvrFlag.LSF_BASIC);
    }
Пример #29
0
    public void Init(string startScriptName = "")
    {
        _startScriptName = startScriptName;

        LuaState.loaderDelegate += LoaderDelegate;

        l = new LuaSvr();
        l.init(null, Complete, LuaSvrFlag.LSF_EXTLIB);
        DontDestroyOnLoad(this);
    }
Пример #30
0
        protected override IEnumerator OnInitCoroutine()
        {
            LuaState.loaderDelegate = ResourceManager.Instance.LoadLuaFile;

            LuaService   = new LuaSvr();
            LuaTableList = new Dictionary <string, LuaTable>();

#if UNITY_EDITOR
            LuaService.init(tick, complete /*, LuaSvrFlag.LSF_DEBUG*/);
#else
            LuaService.init(tick, complete);
#endif

            while (!_isFinished)
            {
                //LoggerHelper.Debug("!LuaEngine.isInitFinished");
                yield return(1);
            }
        }
Пример #31
0
    // Use this for initialization
    void Start()
    {
        luaSvr = new LuaSvr();
        luaSvr.init(null, OnComplete);

        if (d_start != null)
        {
            d_start();
        }
    }
Пример #32
0
        public void TestLuaSvr()
        {
            var luaSvr = new LuaSvr();
            luaSvr.init((x) => { }, () => { });
            var code = @"
local testVar = 12345;
return testVar;
";
            object ret;
            luaSvr.luaState.doBuffer(Encoding.UTF8.GetBytes(code), "TestLua", out ret);
            Assert.AreEqual(ret, 12345);
        }
Пример #33
0
        public void CreateStructVector2()
        {
            var luaSvr = new LuaSvr();
            luaSvr.init(x => { }, () => { });

            var code = @"
            local v = Slua.CreateClass('SLua.Test.TestStruct+Vector2', 1, 2)
            return v
            ";
            var ret = luaSvr.luaState.doString(code);
            Assert.AreEqual(ret, new Vector2(1, 2f));
        }
Пример #34
0
        public void TestSLuaLib()
        {
            var luaSvr = new LuaSvr();
            luaSvr.init(x => { }, () => { });
            var code = @"
local TestSLua = Slua.GetClass('SLua.Test.TestSLua')
return TestSLua
";
            var ret = luaSvr.luaState.doString(code);
            Assert.AreEqual("SLua.LuaClassObject", ret.GetType().ToString());

            var clsField = ret.GetType().GetField("cls", BindingFlags.NonPublic | BindingFlags.Instance);
            var cls = clsField.GetValue(ret);
            Assert.AreEqual(typeof(TestSLua), cls);
        }
Пример #35
0
 public void Init()
 {
     luaSvr = new LuaSvr();
     luaSvr.init(x => { }, () => { });
 }