Skip to content

Commit

Permalink
修复LuaLoop协同功能。
Browse files Browse the repository at this point in the history
  • Loading branch information
jarjin committed Mar 12, 2016
1 parent ba92659 commit d3554e3
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
25 changes: 23 additions & 2 deletions Assets/LuaFramework/Scripts/Manager/LuaManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -20,13 +23,28 @@ public void InitStart() {
InitLuaPath();
InitLuaBundle();
this.lua.Start(); //启动LUAVM
this.StartMain();
this.StartLooper();
}

void StartLooper() {
loop = gameObject.AddComponent<LuaLooper>();
loop.luaState = lua;
}

void StartMain() {
lua.DoFile("Main.lua");

LuaFunction main = lua.GetFunction("Main");
main.Call();
main.Dispose();
main = null;
}

/// <summary>
/// 初始化加载第三方库
/// </summary>
void InitLuaLibrary() {
void OpenLibs() {
lua.OpenLibs(LuaDLL.luaopen_pb);
lua.OpenLibs(LuaDLL.luaopen_sproto_core);
lua.OpenLibs(LuaDLL.luaopen_protobuf_c);
Expand Down Expand Up @@ -92,6 +110,9 @@ public void LuaGC() {
}

public void Close() {
loop.Destroy();
loop = null;

lua.Dispose();
lua = null;
loader = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions Assets/LuaFramework/ToLua/Source/LuaConst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
3 changes: 3 additions & 0 deletions ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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版本

Expand Down

0 comments on commit d3554e3

Please sign in to comment.