Skip to content

Commit 4328343

Browse files
committed
更新tolua#到1.0.6.289版
1 parent fcb74c6 commit 4328343

File tree

12 files changed

+63
-22
lines changed

12 files changed

+63
-22
lines changed

Assets/LuaFramework/Editor/CustomSettings.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,22 @@ public static class CustomSettings
108108
_GT(typeof(AsyncOperation)).SetBaseType(typeof(System.Object)),
109109
_GT(typeof(LightType)),
110110
_GT(typeof(SleepTimeout)),
111+
#if UNITY_5_3_OR_NEWER
112+
_GT(typeof(UnityEngine.Experimental.Director.DirectorPlayer)),
113+
#endif
111114
_GT(typeof(Animator)),
112115
_GT(typeof(Input)),
113116
_GT(typeof(KeyCode)),
114117
_GT(typeof(SkinnedMeshRenderer)),
115118
_GT(typeof(Space)),
116119

117120

118-
_GT(typeof(MeshRenderer)),
121+
_GT(typeof(MeshRenderer)),
122+
#if !UNITY_5_4_OR_NEWER
119123
_GT(typeof(ParticleEmitter)),
120124
_GT(typeof(ParticleRenderer)),
121125
_GT(typeof(ParticleAnimator)),
126+
#endif
122127

123128
_GT(typeof(BoxCollider)),
124129
_GT(typeof(MeshCollider)),
@@ -137,7 +142,8 @@ public static class CustomSettings
137142
_GT(typeof(QualitySettings)),
138143
_GT(typeof(RenderSettings)),
139144
_GT(typeof(BlendWeights)),
140-
_GT(typeof(RenderTexture)),
145+
_GT(typeof(RenderTexture)),
146+
_GT(typeof(Resources)),
141147

142148
//for LuaFramework
143149
_GT(typeof(UIPanel)),
@@ -163,9 +169,11 @@ public static class CustomSettings
163169
public static List<Type> dynamicList = new List<Type>()
164170
{
165171
typeof(MeshRenderer),
172+
#if !UNITY_5_4_OR_NEWER
166173
typeof(ParticleEmitter),
167174
typeof(ParticleRenderer),
168175
typeof(ParticleAnimator),
176+
#endif
169177

170178
typeof(BoxCollider),
171179
typeof(MeshCollider),

Assets/LuaFramework/ToLua/Core/LuaFunction.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public override void Dispose()
6161
base.Dispose();
6262
}
6363

64+
public T ToDelegate<T>() where T: class
65+
{
66+
return DelegateFactory.CreateDelegate(typeof(T), this) as T;
67+
}
68+
6469
public virtual int BeginPCall()
6570
{
6671
if (luaState == null)
@@ -353,11 +358,16 @@ public void PushArgs(object[] args)
353358
luaState.PushArgs(args);
354359
}
355360

356-
public void PushByteBuffer(byte[] buffer)
361+
public void PushByteBuffer(byte[] buffer, int len = -1)
357362
{
358363
try
359364
{
360-
luaState.PushByteBuffer(buffer);
365+
if (len == -1)
366+
{
367+
len = buffer.Length;
368+
}
369+
370+
luaState.PushByteBuffer(buffer, len);
361371
++argCount;
362372
}
363373
catch (Exception e)

Assets/LuaFramework/ToLua/Examples/05_LuaCoroutine/TestCoroutine.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,10 @@ void OnGUI()
4646
func.Call();
4747
func.Dispose();
4848
}
49+
else if (GUI.Button(new Rect(50, 250, 120, 45), "GC"))
50+
{
51+
lua.DoString("collectgarbage('collect')", "TestCoroutine.cs");
52+
Resources.UnloadUnusedAssets();
53+
}
4954
}
5055
}

Assets/LuaFramework/ToLua/Lua/misc/functions.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ local require = require
22
local string = string
33
local table = table
44

5+
function string.split(input, delimiter)
6+
input = tostring(input)
7+
delimiter = tostring(delimiter)
8+
if (delimiter=='') then return false end
9+
local pos,arr = 0, {}
10+
-- for each divider found
11+
for st,sp in function() return string.find(input, delimiter, pos, true) end do
12+
table.insert(arr, string.sub(input, pos, st - 1))
13+
pos = sp + 1
14+
end
15+
table.insert(arr, string.sub(input, pos))
16+
return arr
17+
end
18+
519
function import(moduleName, currentModuleName)
620
local currentModuleNameParts
721
local moduleFullName = moduleName

Assets/LuaFramework/ToLua/Source/Generate/DelegateFactory.cs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55

66
public static class DelegateFactory
77
{
8-
public delegate Delegate DelegateValue(LuaFunction func, LuaTable self, bool flag);
9-
public static Dictionary<Type, DelegateValue> dict = new Dictionary<Type, DelegateValue>();
8+
public delegate Delegate DelegateValue(LuaFunction func, LuaTable self, bool flag);
9+
public static Dictionary<Type, DelegateValue> dict = new Dictionary<Type, DelegateValue>();
1010

11-
static DelegateFactory()
12-
{
13-
Register();
14-
}
11+
static DelegateFactory()
12+
{
13+
Register();
14+
}
1515

16-
[NoToLuaAttribute]
17-
public static void Register()
18-
{
19-
dict.Clear();
20-
}
16+
[NoToLuaAttribute]
17+
public static void Register()
18+
{
19+
dict.Clear();
20+
}
2121

2222
[NoToLuaAttribute]
2323
public static Delegate CreateDelegate(Type t, LuaFunction func = null)
@@ -26,28 +26,28 @@ public static Delegate CreateDelegate(Type t, LuaFunction func = null)
2626

2727
if (!dict.TryGetValue(t, out Create))
2828
{
29-
throw new LuaException(string.Format("Delegate {0} not register", LuaMisc.GetTypeName(t)));
29+
throw new LuaException(string.Format("Delegate {0} not register", LuaMisc.GetTypeName(t)));
3030
}
3131

3232
if (func != null)
3333
{
3434
LuaState state = func.GetLuaState();
3535
LuaDelegate target = state.GetLuaDelegate(func);
36-
36+
3737
if (target != null)
3838
{
3939
return Delegate.CreateDelegate(t, target, target.method);
40-
}
40+
}
4141
else
4242
{
4343
Delegate d = Create(func, null, false);
4444
target = d.Target as LuaDelegate;
4545
state.AddLuaDelegate(target, func);
4646
return d;
47-
}
47+
}
4848
}
4949

50-
return Create(func, null, false);
50+
return Create(func, null, false);
5151
}
5252

5353
[NoToLuaAttribute]
@@ -114,7 +114,7 @@ public static Delegate RemoveDelegate(Delegate obj, Delegate dg)
114114
}
115115

116116
LuaState state = remove.func.GetLuaState();
117-
Delegate[] ds = obj.GetInvocationList();
117+
Delegate[] ds = obj.GetInvocationList();
118118

119119
for (int i = 0; i < ds.Length; i++)
120120
{
@@ -131,5 +131,6 @@ public static Delegate RemoveDelegate(Delegate obj, Delegate dg)
131131

132132
return obj;
133133
}
134+
134135
}
135136

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

Assets/Plugins/iOS/libtolua.a

-1.61 MB
Binary file not shown.
0 Bytes
Binary file not shown.

Assets/Plugins/x86/tolua.dll

7.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)