Skip to content

Commit 217b1bc

Browse files
committed
更新tolua#到1.0.6.253版
1 parent 05a2ab1 commit 217b1bc

File tree

6 files changed

+48
-17
lines changed

6 files changed

+48
-17
lines changed

Assets/LuaFramework/ToLua/Core/LuaDLL.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public string short_src
187187

188188
public class LuaDLL
189189
{
190-
public static string version = "1.0.6.244";
190+
public static string version = "1.0.6.250";
191191
public static int LUA_MULTRET = -1;
192192
public static string[] LuaTypeName = { "none", "nil", "boolean", "lightuserdata", "number", "string", "table", "function", "userdata", "thread" };
193193

Assets/LuaFramework/ToLua/Core/LuaState.cs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ public void EndPreModule(int reference)
284284
LuaDLL.tolua_endpremodule(L, reference);
285285
}
286286

287+
public void EndPreModule(IntPtr L, int reference)
288+
{
289+
--beginCount;
290+
LuaDLL.tolua_endpremodule(L, reference);
291+
}
292+
287293
public void BindPreModule(Type t, LuaCSFunction func)
288294
{
289295
preLoadMap[t] = func;
@@ -794,12 +800,14 @@ bool PushLuaFunction(string fullPath, bool checkMap = true)
794800
void RemoveFromGCList(int reference)
795801
{
796802
lock (gcList)
797-
{
798-
int index = gcList.FindIndex((gc) => { return gc.reference == reference; });
799-
800-
if (index >= 0)
803+
{
804+
for (int i = 0; i < gcList.Count; i++)
801805
{
802-
gcList.RemoveAt(index);
806+
if (gcList[i].reference == reference)
807+
{
808+
gcList.RemoveAt(i);
809+
break;
810+
}
803811
}
804812
}
805813
}
@@ -1237,9 +1245,9 @@ public void PushObject(object obj)
12371245
{
12381246
if (obj.GetType().IsEnum)
12391247
{
1240-
ToLua.Push(L, (Enum)obj);
1248+
ToLua.Push(L, (Enum)obj);
12411249
}
1242-
else
1250+
else
12431251
{
12441252
ToLua.PushObject(L, obj);
12451253
}
@@ -1848,13 +1856,13 @@ public void PrintTable(string name)
18481856
{
18491857
LuaTable table = GetTable(name);
18501858
LuaDictTable dict = table.ToDictTable();
1851-
table.Dispose();
1859+
table.Dispose();
18521860
var iter2 = dict.GetEnumerator();
18531861

1854-
while (iter2.MoveNext())
1855-
{
1856-
Debugger.Log("map item, k,v is {0}:{1}", iter2.Current.Key, iter2.Current.Value);
1857-
}
1862+
while (iter2.MoveNext())
1863+
{
1864+
Debugger.Log("map item, k,v is {0}:{1}", iter2.Current.Key, iter2.Current.Value);
1865+
}
18581866

18591867
iter2.Dispose();
18601868
dict.Dispose();

Assets/LuaFramework/ToLua/Editor/ToLuaMenu.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ static void GenPreLoadFunction(BindType bt, StringBuilder sb)
755755
sb.AppendFormat("\t\t\tstate.BeginPreModule(\"{0}\");\r\n", bt.nameSpace);
756756
sb.AppendFormat("\t\t\t{0}Wrap.Register(state);\r\n", bt.wrapName);
757757
sb.AppendFormat("\t\t\tint reference = state.GetMetaReference(typeof({0}));\r\n", bt.name);
758-
sb.AppendLineEx("\t\t\tstate.EndPreModule(reference);");
758+
sb.AppendLineEx("\t\t\tstate.EndPreModule(L, reference);");
759759
sb.AppendLineEx("\t\t\treturn 1;");
760760
sb.AppendLineEx("\t\t}");
761761
sb.AppendLineEx("\t\tcatch(Exception e)");

Assets/LuaFramework/ToLua/Lua/UnityEngine/LayerMask.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function LayerMask.GetMask(...)
3838
for i = 1, #arg do
3939
local n = LayerMask.NameToLayer(arg[i])
4040

41-
if n ~= 0 then
41+
if n ~= nil then
4242
value = value + 2 ^ n
4343
end
4444
end

Assets/LuaFramework/ToLua/Misc/LuaClient.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2525
using System.Collections;
2626
using System.IO;
2727
using System;
28+
using UnityEngine.SceneManagement;
2829

2930
public class LuaClient : MonoBehaviour
3031
{
@@ -171,6 +172,10 @@ protected void Awake()
171172
{
172173
Instance = this;
173174
Init();
175+
176+
#if UNITY_5_4
177+
SceneManager.sceneLoaded += OnSceneLoaded;
178+
#endif
174179
}
175180

176181
protected virtual void OnLoadFinished()
@@ -180,7 +185,7 @@ protected virtual void OnLoadFinished()
180185
StartMain();
181186
}
182187

183-
protected void OnLevelWasLoaded(int level)
188+
void OnLevelLoaded(int level)
184189
{
185190
if (levelLoaded != null)
186191
{
@@ -191,10 +196,25 @@ protected void OnLevelWasLoaded(int level)
191196
}
192197
}
193198

194-
protected void Destroy()
199+
#if UNITY_5_4
200+
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
201+
{
202+
OnLevelLoaded(scene.buildIndex);
203+
}
204+
#else
205+
protected void OnLevelWasLoaded(int level)
206+
{
207+
OnLevelLoaded(level);
208+
}
209+
#endif
210+
211+
public virtual void Destroy()
195212
{
196213
if (luaState != null)
197214
{
215+
#if UNITY_5_4
216+
SceneManager.sceneLoaded -= OnSceneLoaded;
217+
#endif
198218
LuaState state = luaState;
199219
luaState = null;
200220

ReadMe.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ tolua#地址: https://github.com/topameng/tolua
1616
XlsxToLua: https://github.com/zhangqi-ulua/XlsxToLua
1717
UnityHello: https://github.com/woshihuo12/UnityHello
1818

19+
//-------------2016-09-18-------------
20+
(1)更新tolua#到1.0.6.253版
21+
1922
//-------------2016-09-09-------------
2023
(1)更新tolua#到1.0.6.248版
2124

0 commit comments

Comments
 (0)