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"); } }); } }
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(); } }
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); }
// 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); } }
void Start() { luaSvr = new LuaSvr(); luaSvr.init(null, () => { luaSvr.start("useLua"); }, LuaSvrFlag.LSF_DEBUG); }
// Use this for initialization void Start() { l = new LuaSvr(); l.init(null, () => { l.start("delegate"); }); }
public void Startup() { #if !UNITY_EDITOR LuaFileCache.Instance.InitLuaBytecode(); #endif luaSvr.init(ScriptLoadTick, ScriptLoadCompleted, LuaSvrFlag.LSF_BASIC); }
// Use this for initialization void Start() { l = new LuaSvr(); l.init(null, () => { l.start("LuaTest"); }); }
// Use this for initialization void Start() { l = new LuaSvr(); l.init(null, () => { l.start("varobj"); }); }
// Use this for initialization void Start() { l = new LuaSvr(); l.init(null, () => { l.start("valuetype"); }); }
// Use this for initialization void Start() { luaSvr = new LuaSvr(); luaSvr.init(null, () => { self = (LuaTable)luaSvr.start("startGame"); }); }
public void Init() { LuaState.loaderDelegate += LoaderDelegate; l = new LuaSvr(); l.init(null, Complete, LuaSvrFlag.LSF_EXTLIB); DontDestroyOnLoad(this); }
private LuaModule() { #if UNITY_EDITOR UnityEngine.Debug.Log("Consturct LuaModule..."); #endif _luaSvr = new LuaSvr(); _luaSvr.init(progress => { }, () => { }); }
void Start() { svr = new LuaSvr(); svr.init(null, () => { self = (LuaTable)svr.start("skynet/main"); }, LuaSvrFlag.LSF_EXTLIB); }
void Start() { c = this; l = new LuaSvr(); l.init(null, () => { l.start("BindCSharp"); }); }
void Start() { c = this; l = new LuaSvr(); l.init(null, () => { l.start("custom"); }); }
void Start() { luaSvr = new LuaSvr(); LuaSvr.mainState.loaderDelegate += LuaLoader; luaSvr.init(null, () => { luaSvr.start("CreatePrefab.Lua"); }); }
void Start() { luaSvr = new LuaSvr(); LuaSvr.mainState.loaderDelegate += LuaLoader; luaSvr.init(null, () => { luaSvr.start("MyPackage.Lua"); }); }
///////////////////////////////////////////////////////// /// <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 }
void Start() { svr = new LuaSvr(); svr.init(null, () => { self = (LuaTable)svr.start("circle/circle"); update = (LuaFunction)self["update"]; }); }
void Start() { luaSvr = new LuaSvr(); LuaSvr.mainState.loaderDelegate += LuaLoader; luaSvr.init(null, () => { luaSvr.start("UseCSharpClass.Lua"); }); }
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"]; }); }
private void Awake() { LuaSvr svr = new LuaSvr(); svr.init(null, () => { svr.start("06_RequireImport/06_RequireImport"); }); }
/// <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); }
void Start() { svr = new LuaSvr(); svr.init(null, () => { self = (LuaTable)svr.start("circle/circles"); update = (LuaFunction)self["update"]; ud = update.cast <UpdateDelegate>(); }); }
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); }
public void Init(string startScriptName = "") { _startScriptName = startScriptName; LuaState.loaderDelegate += LoaderDelegate; l = new LuaSvr(); l.init(null, Complete, LuaSvrFlag.LSF_EXTLIB); DontDestroyOnLoad(this); }
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); } }
// Use this for initialization void Start() { luaSvr = new LuaSvr(); luaSvr.init(null, OnComplete); if (d_start != null) { d_start(); } }
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); }
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)); }
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); }
public void Init() { luaSvr = new LuaSvr(); luaSvr.init(x => { }, () => { }); }