void Start() { #if UNITY_5 || UNITY_2017_1_OR_NEWER Application.logMessageReceived += Log; #else Application.RegisterLogCallback(Log); #endif lua = new LuaState(); lua.Start(); //如果移动了ToLua目录,自己手动修复吧,只是例子就不做配置了 string fullPath = Application.dataPath + "\\ToLua/Examples/02_ScriptsFromFile"; lua.AddSearchPath(fullPath); }
void Start() { #if UNITY_5 || UNITY_2017 || UNITY_2018 Application.logMessageReceived += Log; #else Application.RegisterLogCallback(Log); #endif lua = new LuaState(); lua.Start(); string fullPath = Application.dataPath + "\\ToLua/Examples/02_ScriptsFromFile"; lua.AddSearchPath(fullPath); // 将上述路径添加至lua可搜索路径里 }
private void Start() { luaState = new LuaState(); luaState.Start(); luaState.AddSearchPath(Application.dataPath + "\\ScrollEnhancement"); DelegateFactory.Init(); LuaBinder.Bind(luaState); LuaLooper looper = gameObject.AddComponent <LuaLooper>(); looper.luaState = luaState; luaState.Require("Test.Main"); }
void Start() { #if UNITY_5 || UNITY_2017 || UNITY_2018 Application.logMessageReceived += Log; #else Application.RegisterLogCallback(Log); #endif lua = new LuaState(); lua.Start(); string fullPath = Application.dataPath + "\\TestExample/2"; lua.AddSearchPath(fullPath); }
void StartGame(GameObject obj, object param) { abManager = new ABManager(); abManager.LoadAB(AppConfig.SearchUIABPath + "comm.tex"); luaState = new LuaState(); luaState.AddSearchPath(AppConfig.SearchGameLuaPath); LuaBinder.Bind(luaState); luaState.Start(); luaState.DoFile("Others/main.lua"); luaState.CheckTop(); //luaState.Dispose(); luaState = null; }
public void OpenZbsDebugger(string ip = "localhost") { if (!LuaConst.openLuaSocket) { OpenLuaSocket(); } if (!string.IsNullOrEmpty(LuaConst.zbsDir)) { luaState.AddSearchPath(LuaConst.zbsDir); } luaState.LuaDoString(string.Format("DebugServerIp = '{0}'", ip)); }
private void Start() { var lua = new LuaState(); lua.Start(); string fullPath = Application.dataPath + "\\EmmyTypeGenerator/Lua"; lua.AddSearchPath(fullPath); DelegateFactory.Init(); LuaBinder.Bind(lua); lua.Require("Test"); }
void Start() { new LuaResLoader(); lua = new LuaState(); lua.Start(); string fullPath = Application.dataPath + "Game/Lua"; lua.AddSearchPath(fullPath); lua.Start(); LuaBinder.Bind(lua); lua.DoFile("main.lua"); lua.CheckTop(); }
void Start() { // 为自身带有 [Inject] 特性的成员进行注入 this.Inject(); lua = new LuaState(); lua.Start(); LuaBinder.Bind(lua); // 如果移动了目录,请自行调整为相应路径 string fullPath = Application.dataPath + "\\Files/lua/Examples/02_BindingGameObjects"; lua.AddSearchPath(fullPath); lua.Require("LuaRotator"); func = lua.GetFunction("test.Func"); }
public void OpenZbsDebugger(string ip = "localhost") { if (!Directory.Exists(LuaConst.zbsDir)) { Debugger.LogWarning("ZeroBraneStudio not install or LuaConst.zbsDir not right"); return; } if (!string.IsNullOrEmpty(LuaConst.zbsDir)) { luaState.AddSearchPath(LuaConst.zbsDir); } luaState.LuaDoString(string.Format("DebugServerIp = '{0}'", ip), "@LuaClient.cs"); }
// Start is called before the first frame update void Start() { version = 3; LoadLua(); LoadPrefabs(); new LuaResLoader(); lua = new LuaState(); lua.Start(); LuaBinder.Bind(lua); string luaPath = Application.dataPath + "/Lua"; lua.AddSearchPath(luaPath); lua.DoFile("TestLua.lua"); Callfunc("Control.Start"); }
// Use this for initialization void Start() { // creat lua Virtual Mechine m_state = new LuaState(); // start lua VM m_state.Start(); // add lua search path string path = AppConst.FrameworkRoot + Path.DirectorySeparatorChar + "Lua/TestToLuaC"; m_state.AddSearchPath(path); // TestToLua1(); TestToLua2(); }
protected virtual void InitLuaPath() { #if UNITY_EDITOR if (!Directory.Exists(LuaConst.luaDir)) { string msg = string.Format("luaDir path not exists: {0}, configer it in LuaConst.cs", LuaConst.luaDir); throw new LuaException(msg); } if (!Directory.Exists(LuaConst.toluaDir)) { string msg = string.Format("toluaDir path not exists: {0}, configer it in LuaConst.cs", LuaConst.toluaDir); throw new LuaException(msg); } luaState.AddSearchPath(LuaConst.toluaDir); luaState.AddSearchPath(LuaConst.luaDir); #endif if (!AppConst.LuaBundleMode) { luaState.AddSearchPath(LuaConst.luaResDir); luaState.AddSearchPath(LuaConst.streamingAssetLua); } }
void Start() { LuaState lua = new LuaState(); lua.Start(); string fullPath = Application.dataPath + "/ToLua/Examples/02_ScriptsFromFile"; lua.AddSearchPath(fullPath); lua.DoFile("ScriptsFromFile.lua"); //lua.DoString("require 'ScriptsFromFile'"); //lua.Require("ScriptsFromFile"); lua.Dispose(); }
void Init() { //InitLoader(); luaState = new LuaState(); OpenLibs(); luaState.LuaSetTop(0); Bind(); //LoadLuaFiles(); string fullPath = Application.dataPath + "/UFrame/A_LuaTest"; luaState.AddSearchPath(fullPath); luaState.Start(); }
private void Start() { luaState = new LuaState(); luaState.Start(); DelegateFactory.Init(); string fullPath = Path.Combine(Application.dataPath, @"My/03_CallLuaFunction"); luaState.AddSearchPath(fullPath); luaState.Require("CallLuaFunction"); Call(); Invoke(); PushFunc(); Delegate(); LuaInvoke(); }
/// 初始化Lua代码加载路径; void InitLuaPath() { #if UNITY_EDITOR RequirePathList = new List <string>(); RequirePathList.Add(LuaConst.luaDir); RequirePathList.Add(LuaConst.luaResDir); RequirePathList.Add(Application.dataPath + "/LuaFramework/Lua/NetWork"); if (!loader.beZip) { foreach (var path in RequirePathList) { lua.AddSearchPath(path); } } #endif }
void Start() { lua = new LuaState(); lua.Start(); //添加搜索路径 string fullPath = Application.dataPath + "/Example/HotReload/Lua"; lua.AddSearchPath(fullPath); lua.Require("GameMain"); // lua.DoString("GameMain.start()"); //创建lua 文件监听器 LuaFileWatcher.CreateLuaFileWatcher(lua, fullPath); }
// Use this for initialization void Start() { new LuaResLoader(); lua = new LuaState(); lua.LogGC = true; lua.Start(); LuaBinder.Bind(lua); DelegateFactory.Init(); looper = gameObject.AddComponent <LuaLooper>(); looper.luaState = lua; lua["UnityEngine.PrimitiveType.Cube"] = PrimitiveType.Cube; lua["UnityEngine.PrimitiveType.Sphere"] = PrimitiveType.Sphere; string fullPath = Application.dataPath + "/Example"; lua.AddSearchPath(fullPath); lua.DoFile("hx.lua"); }
//初始化函数,可以被重写,已添加其他 protected bool Init() { // s_luaState = LuaTest.Instance.GetLuaState(); new LuaResLoader(); s_luaState = new LuaState(); s_luaState.Start(); LuaBinder.Bind(s_luaState); s_luaState.AddSearchPath(Application.streamingAssetsPath + "\\Lua"); if (string.IsNullOrEmpty(LuaPath)) { Debug.Log(LuaPath); return(false); } s_luaState.DoFile(LuaPath); // mSelfTable = s_luaState.GetTable(0); // mSelfTable = s_luaState.GetTable(LuaPath.Replace(".lua","")); // mSelfTable = s_luaState.GetTable("Bullet"); LuaFunction func = s_luaState.GetFunction("GetTable"); func.BeginPCall(); func.PCall(); mSelfTable = func.CheckLuaTable(); func.EndPCall(); if (null == mSelfTable) { Debug.LogError("null == luaTable " + LuaPath); return(false); } AddFunc(FuncName.Awake); AddFunc(FuncName.OnEnable); AddFunc(FuncName.Start); AddFunc(FuncName.Update); AddFunc(FuncName.OnDisable); AddFunc(FuncName.OnDestroy); foreach (var item in mDicFunc) { Debug.Log("------------------" + item); } return(true); }
/// <summary> /// 初始化Lua代码加载路径 /// </summary> private void InitLuaPath() { #if UNITY_EDITOR string _path = Application.dataPath + "/GameContent/Modules"; string[] _dirs = System.IO.Directory.GetDirectories(_path, "*", System.IO.SearchOption.AllDirectories); for (int i = 0; i < _dirs.Length; i++) { string _one = _dirs[i].ToLower(); _one = Utility.MakeUnifiedDirectory(_one); if (_one.EndsWith("/")) { _one = _one.Substring(0, _one.Length - 1); } if (_one.EndsWith("lua") || _one.EndsWith("tolua")) { lua.AddSearchPath(_dirs[i]); } } #endif }
public void OpenZbsDebugger(string ip = null) { if (!LuaConst.openLuaSocket) { LuaConst.openLuaSocket = true; luaState.OpenLibs(LuaDLL.luaopen_socket_core); luaState.OpenLibs(LuaDLL.luaopen_luasocket_scripts); } luaState.AddSearchPath(LuaConst.zbsDir); if (ip != null) { luaState.DoString(string.Format("require('mobdebug').start('{0}')", ip)); } else { luaState.DoString("require('mobdebug').start()"); } }
public void Init() { _loader = new LuaLoader(); _lua = new LuaState(); OpenLibs(); LuaBinder.Bind(_lua); DelegateFactory.Register(); LuaCoroutine.Register(_lua, this); // Lua读取路径 LuaFileUtils.Instance.beZip = AppConst.resourceMode != 0; // 如果是打包模式,读AB,否则读Lua目录 if (LuaFileUtils.Instance.beZip) { _loader.AddBundle("lua_ui"); _loader.AddBundle("lua_logic"); _loader.AddBundle("lua_protobuf"); _loader.AddBundle("lua_protocols"); _loader.AddBundle("lua_tolua"); _loader.AddBundle("lua_fight"); _loader.AddBundle("lua_character"); _loader.AddBundle("lua_utils"); _loader.AddBundle("lua_skill"); _loader.AddBundle("lua_cache"); } else { _lua.AddSearchPath(LuaConst.luaDir); } //启动LuaVM _lua.Start(); // Lua计时 gameObject.AddComponent <LuaLooper>().luaState = _lua; // 添加lua之间的引用关系 DoFile("logic/Main"); }
void Start() { lua = new LuaState(); lua.Start(); LuaBinder.Bind(lua); // 获取 RotateController 的 lua 属性,并将其设置给 LuaLooper 的 luaState SetUpLuaLooper(); // 如果移动了目录,请自行调整为相应路径 string fullPath = Application.dataPath + "\\Files/lua/Examples/03_UsingConditions"; lua.AddSearchPath(fullPath); lua.Require("LuaCoroutineRotator"); // 将 RightCube 传入 lua lua["transform"] = RightCube; func = lua.GetFunction("StartDelay"); // 调用 lua 方法,由 LuaLooper 来协调 lua 脚本进行 Coroutine 使 RightCube 旋转 CallFunc(); }
public void Init() { #if UNITY_EDITOR LuaState.AddSearchPath(LuaFileFolder); #endif LuaState.Start(); LuaManager.LoadLuaFile("Main"); LuaFunction main = LuaState.GetFunction("Main"); main.Call(); main.Dispose(); LuaState.Collect(); Debug.Log(GC.GetTotalMemory(true)); Debug.Log(GC.GetTotalMemory(false)); for (int i = 0; i < GC.MaxGeneration; i++) { Debug.Log(GC.CollectionCount(i)); } GC.Collect(); }
void Start() { #if UNITY_5 || UNITY_2017 || UNITY_2018 Application.logMessageReceived += Log; #else Application.RegisterLogCallback(Log); #endif lua = new LuaState(); lua.Start(); LuaBinder.Bind(lua); //如果移动了ToLua目录,自己手动修复吧,只是例子就不做配置了 string fullPath = Application.dataPath + "\\ToLua/Examples/02_ScriptsFromFile"; lua.AddSearchPath(fullPath); lua.DoString(@" local GameObject = UnityEngine.GameObject fk1 = { k1 = { kk1 = GameObject('go') }, k2 = {} } kk = {} local x = fk1.k2 function test() return xZ end function freex() x = nil end go = GameObject('go') "); }
public void OnInit() { LuaState = new LuaState(); this.OpenLibs(); LuaState.LuaSetTop(0); LuaBinder.Bind(LuaState); LuaCoroutine.Register(LuaState, this); #if UNITY_EDITOR if (!string.IsNullOrEmpty(LuaConst.luaDir)) { foreach (var subDir in Directory.GetDirectories(LuaConst.luaDir, "*", SearchOption.AllDirectories)) { LuaState.AddSearchPath(subDir); } } #endif LuaState.Start(); LuaHelper.CallFunction("Main.Init"); }
// 游戏开始 private void Start() { Instance = this; luaState = new LuaState(); luaState.Start(); LuaBinder.Bind(luaState); looper = gameObject.AddComponent <LuaLooper>(); looper.luaState = luaState; string path = ResourceConfig.LuaPath; luaState.AddSearchPath(path); luaState.DoFile("GameMain.lua"); // 执行游戏核心初始化函数 LuaFunction initFunc = luaState.GetFunction("Init"); initFunc.Call(); initFunc.Dispose(); initFunc = null; }
/// <summary> /// Inititialize the Lua runtime environment /// </summary> /// <remarks> /// This method should be called before any Nova-related code runs. The beginning of Start or Awake /// of GameController might be a good choice. /// </remarks> private void Init() { if (inited) { return; } new LuaResLoader(); DelegateFactory.Init(); lua = new LuaState(); lua.Start(); LuaBinder.Bind(lua); // Enable coroutine var looper = gameObject.AddComponent <LuaLooper>(); looper.luaState = lua; lua.AddSearchPath(Application.dataPath + "/Nova/Lua"); Reset(); inited = true; }
// Use this for initialization void Start() { if (luaState == null) { luaState = new LuaState(); luaState.Start(); luaState.LuaCheckStack(200); luaState.CheckTop(); LuaBinder.Bind(luaState); luaState.AddSearchPath(Application.dataPath + "\\Scripts/lua"); luaState.DoFile("lua_bridge.lua"); luaInit = luaState.GetFunction("lua_init"); luaUpdate = luaState.GetFunction("lua_update"); int _ref = luaInit.BeginPCall(); luaInit.PCall(); object[] tb = luaState.CheckObjects(_ref); luaInit.EndPCall(); luaRoot = tb[0] as LuaTable; } Init(); }