diff --git a/Assets/LuaFramework/Scripts/Manager/LuaManager.cs b/Assets/LuaFramework/Scripts/Manager/LuaManager.cs index 227ccda59..9610c0d86 100644 --- a/Assets/LuaFramework/Scripts/Manager/LuaManager.cs +++ b/Assets/LuaFramework/Scripts/Manager/LuaManager.cs @@ -6,12 +6,15 @@ namespace LuaFramework { public class LuaManager : Manager { private LuaState lua; private LuaLoader loader; + private LuaLooper loop = null; // Use this for initialization void Awake() { loader = new LuaLoader(); lua = new LuaState(); - this.InitLuaLibrary(); + this.OpenLibs(); + lua.LuaSetTop(0); + LuaBinder.Bind(lua); LuaCoroutine.Register(lua, this); } @@ -20,13 +23,28 @@ public void InitStart() { InitLuaPath(); InitLuaBundle(); this.lua.Start(); //启动LUAVM + this.StartMain(); + this.StartLooper(); + } + + void StartLooper() { + loop = gameObject.AddComponent(); + loop.luaState = lua; + } + + void StartMain() { lua.DoFile("Main.lua"); + + LuaFunction main = lua.GetFunction("Main"); + main.Call(); + main.Dispose(); + main = null; } /// /// 初始化加载第三方库 /// - void InitLuaLibrary() { + void OpenLibs() { lua.OpenLibs(LuaDLL.luaopen_pb); lua.OpenLibs(LuaDLL.luaopen_sproto_core); lua.OpenLibs(LuaDLL.luaopen_protobuf_c); @@ -92,6 +110,9 @@ public void LuaGC() { } public void Close() { + loop.Destroy(); + loop = null; + lua.Dispose(); lua = null; loader = null; diff --git a/Assets/LuaFramework/ToLua/Examples/02_ScriptsFromFile/ScriptsFromFile.cs b/Assets/LuaFramework/ToLua/Examples/02_ScriptsFromFile/ScriptsFromFile.cs index f89b4ed32..338d36fdd 100644 --- a/Assets/LuaFramework/ToLua/Examples/02_ScriptsFromFile/ScriptsFromFile.cs +++ b/Assets/LuaFramework/ToLua/Examples/02_ScriptsFromFile/ScriptsFromFile.cs @@ -19,7 +19,7 @@ void Start () #endif lua = new LuaState(); lua.Start(); - string fullPath = Application.dataPath + "/ToLua/Examples/02_ScriptsFromFile"; + string fullPath = Application.dataPath + "/LuaFramework/ToLua/Examples/02_ScriptsFromFile"; lua.AddSearchPath(fullPath); } diff --git a/Assets/LuaFramework/ToLua/Source/LuaConst.cs b/Assets/LuaFramework/ToLua/Source/LuaConst.cs index 84aabd7a8..31d994ad9 100644 --- a/Assets/LuaFramework/ToLua/Source/LuaConst.cs +++ b/Assets/LuaFramework/ToLua/Source/LuaConst.cs @@ -2,6 +2,6 @@ public static class LuaConst { - public static string luaDir = Application.dataPath + "/Lua"; - public static string toluaDir = Application.dataPath + "/ToLua/Lua"; + public static string luaDir = Application.dataPath + "/LuaFramework/Lua"; + public static string toluaDir = Application.dataPath + "/LuaFramework/ToLua/Lua"; } \ No newline at end of file diff --git a/ReadMe.txt b/ReadMe.txt index b50876bd3..7b5786059 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -15,6 +15,9 @@ tolua#地址: https://github.com/topameng/tolua tolua#底层库 https://github.com/topameng/tolua_runtime 服务器框架: https://github.com/jarjin/ServerFramework +//-------------2016-03-12------------- +(1)修复LuaLoop协同功能。 + //-------------2016-03-06------------- (1)更新tolua #到1.03版本