Skip to content

Commit 8db66d3

Browse files
committed
Add tolua.
1 parent 0a4056f commit 8db66d3

File tree

683 files changed

+113192
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

683 files changed

+113192
-0
lines changed

Assets/ToLua/Editor.meta

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/ToLua/Editor/Custom.meta

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
using UnityEngine;
2+
using System;
3+
using System.Collections.Generic;
4+
using LuaInterface;
5+
using UnityEditor;
6+
7+
using BindType = ToLuaMenu.BindType;
8+
using System.Reflection;
9+
10+
public static class CustomSettings
11+
{
12+
public static string saveDir = Application.dataPath + "/ToLua/Source/Generate/";
13+
public static string toluaBaseType = Application.dataPath + "/ToLua/ToLua/BaseType/";
14+
public static string baseLuaDir = Application.dataPath + "/ToLua/ToLua/Lua/";
15+
public static string injectionFilesPath = Application.dataPath + "/ToLua/ToLua/Injection/";
16+
17+
//导出时强制做为静态类的类型(注意customTypeList 还要添加这个类型才能导出)
18+
//unity 有些类作为sealed class, 其实完全等价于静态类
19+
public static List<Type> staticClassTypes = new List<Type>
20+
{
21+
typeof(UnityEngine.Application),
22+
typeof(UnityEngine.Time),
23+
typeof(UnityEngine.Screen),
24+
typeof(UnityEngine.SleepTimeout),
25+
typeof(UnityEngine.Input),
26+
typeof(UnityEngine.Resources),
27+
typeof(UnityEngine.Physics),
28+
typeof(UnityEngine.RenderSettings),
29+
typeof(UnityEngine.QualitySettings),
30+
typeof(UnityEngine.GL),
31+
typeof(UnityEngine.Graphics),
32+
};
33+
34+
//附加导出委托类型(在导出委托时, customTypeList 中牵扯的委托类型都会导出, 无需写在这里)
35+
public static DelegateType[] customDelegateList =
36+
{
37+
_DT(typeof(Action)),
38+
_DT(typeof(UnityEngine.Events.UnityAction)),
39+
_DT(typeof(System.Predicate<int>)),
40+
_DT(typeof(System.Action<int>)),
41+
_DT(typeof(System.Comparison<int>)),
42+
_DT(typeof(System.Func<int, int>)),
43+
};
44+
45+
//在这里添加你要导出注册到lua的类型列表
46+
public static BindType[] customTypeList =
47+
{
48+
//------------------------为例子导出--------------------------------
49+
//_GT(typeof(TestEventListener)),
50+
//_GT(typeof(TestProtol)),
51+
//_GT(typeof(TestAccount)),
52+
//_GT(typeof(Dictionary<int, TestAccount>)).SetLibName("AccountMap"),
53+
//_GT(typeof(KeyValuePair<int, TestAccount>)),
54+
//_GT(typeof(Dictionary<int, TestAccount>.KeyCollection)),
55+
//_GT(typeof(Dictionary<int, TestAccount>.ValueCollection)),
56+
//_GT(typeof(TestExport)),
57+
//_GT(typeof(TestExport.Space)),
58+
//-------------------------------------------------------------------
59+
60+
_GT(typeof(LuaInjectionStation)),
61+
_GT(typeof(InjectType)),
62+
_GT(typeof(Debugger)).SetNameSpace(null),
63+
64+
#if USING_DOTWEENING
65+
_GT(typeof(DG.Tweening.DOTween)),
66+
_GT(typeof(DG.Tweening.Tween)).SetBaseType(typeof(System.Object)).AddExtendType(typeof(DG.Tweening.TweenExtensions)),
67+
_GT(typeof(DG.Tweening.Sequence)).AddExtendType(typeof(DG.Tweening.TweenSettingsExtensions)),
68+
_GT(typeof(DG.Tweening.Tweener)).AddExtendType(typeof(DG.Tweening.TweenSettingsExtensions)),
69+
_GT(typeof(DG.Tweening.LoopType)),
70+
_GT(typeof(DG.Tweening.PathMode)),
71+
_GT(typeof(DG.Tweening.PathType)),
72+
_GT(typeof(DG.Tweening.RotateMode)),
73+
_GT(typeof(Component)).AddExtendType(typeof(DG.Tweening.ShortcutExtensions)),
74+
_GT(typeof(Transform)).AddExtendType(typeof(DG.Tweening.ShortcutExtensions)),
75+
_GT(typeof(Light)).AddExtendType(typeof(DG.Tweening.ShortcutExtensions)),
76+
_GT(typeof(Material)).AddExtendType(typeof(DG.Tweening.ShortcutExtensions)),
77+
_GT(typeof(Rigidbody)).AddExtendType(typeof(DG.Tweening.ShortcutExtensions)),
78+
_GT(typeof(Camera)).AddExtendType(typeof(DG.Tweening.ShortcutExtensions)),
79+
_GT(typeof(AudioSource)).AddExtendType(typeof(DG.Tweening.ShortcutExtensions)),
80+
//_GT(typeof(LineRenderer)).AddExtendType(typeof(DG.Tweening.ShortcutExtensions)),
81+
//_GT(typeof(TrailRenderer)).AddExtendType(typeof(DG.Tweening.ShortcutExtensions)),
82+
#else
83+
84+
_GT(typeof(Component)),
85+
_GT(typeof(Transform)),
86+
_GT(typeof(Material)),
87+
_GT(typeof(Light)),
88+
_GT(typeof(Rigidbody)),
89+
_GT(typeof(Camera)),
90+
_GT(typeof(AudioSource)),
91+
//_GT(typeof(LineRenderer))
92+
//_GT(typeof(TrailRenderer))
93+
#endif
94+
95+
_GT(typeof(Behaviour)),
96+
_GT(typeof(MonoBehaviour)),
97+
_GT(typeof(GameObject)),
98+
_GT(typeof(TrackedReference)),
99+
_GT(typeof(Application)),
100+
_GT(typeof(Physics)),
101+
_GT(typeof(Collider)),
102+
_GT(typeof(Time)),
103+
_GT(typeof(Texture)),
104+
_GT(typeof(Texture2D)),
105+
_GT(typeof(Shader)),
106+
_GT(typeof(Renderer)),
107+
_GT(typeof(WWW)),
108+
_GT(typeof(Screen)),
109+
_GT(typeof(CameraClearFlags)),
110+
_GT(typeof(AudioClip)),
111+
_GT(typeof(AssetBundle)),
112+
_GT(typeof(ParticleSystem)),
113+
_GT(typeof(AsyncOperation)).SetBaseType(typeof(System.Object)),
114+
_GT(typeof(LightType)),
115+
_GT(typeof(SleepTimeout)),
116+
#if UNITY_5_3_OR_NEWER && !UNITY_5_6_OR_NEWER
117+
_GT(typeof(UnityEngine.Experimental.Director.DirectorPlayer)),
118+
#endif
119+
_GT(typeof(Animator)),
120+
_GT(typeof(Input)),
121+
_GT(typeof(KeyCode)),
122+
_GT(typeof(SkinnedMeshRenderer)),
123+
_GT(typeof(Space)),
124+
125+
126+
_GT(typeof(MeshRenderer)),
127+
#if !UNITY_5_4_OR_NEWER
128+
_GT(typeof(ParticleEmitter)),
129+
_GT(typeof(ParticleRenderer)),
130+
_GT(typeof(ParticleAnimator)),
131+
#endif
132+
133+
_GT(typeof(BoxCollider)),
134+
_GT(typeof(MeshCollider)),
135+
_GT(typeof(SphereCollider)),
136+
_GT(typeof(CharacterController)),
137+
_GT(typeof(CapsuleCollider)),
138+
139+
_GT(typeof(Animation)),
140+
_GT(typeof(AnimationClip)).SetBaseType(typeof(UnityEngine.Object)),
141+
_GT(typeof(AnimationState)),
142+
_GT(typeof(AnimationBlendMode)),
143+
_GT(typeof(QueueMode)),
144+
_GT(typeof(PlayMode)),
145+
_GT(typeof(WrapMode)),
146+
147+
_GT(typeof(QualitySettings)),
148+
_GT(typeof(RenderSettings)),
149+
_GT(typeof(SkinWeights)),
150+
_GT(typeof(RenderTexture)),
151+
_GT(typeof(Resources)),
152+
_GT(typeof(LuaProfiler)),
153+
};
154+
155+
public static List<Type> dynamicList = new List<Type>()
156+
{
157+
typeof(MeshRenderer),
158+
#if !UNITY_5_4_OR_NEWER
159+
typeof(ParticleEmitter),
160+
typeof(ParticleRenderer),
161+
typeof(ParticleAnimator),
162+
#endif
163+
164+
typeof(BoxCollider),
165+
typeof(MeshCollider),
166+
typeof(SphereCollider),
167+
typeof(CharacterController),
168+
typeof(CapsuleCollider),
169+
170+
typeof(Animation),
171+
typeof(AnimationClip),
172+
typeof(AnimationState),
173+
174+
typeof(SkinWeights),
175+
typeof(RenderTexture),
176+
typeof(Rigidbody),
177+
};
178+
179+
//重载函数,相同参数个数,相同位置out参数匹配出问题时, 需要强制匹配解决
180+
//使用方法参见例子14
181+
public static List<Type> outList = new List<Type>()
182+
{
183+
184+
};
185+
186+
//ngui优化,下面的类没有派生类,可以作为sealed class
187+
public static List<Type> sealedList = new List<Type>()
188+
{
189+
/*typeof(Transform),
190+
typeof(UIRoot),
191+
typeof(UICamera),
192+
typeof(UIViewport),
193+
typeof(UIPanel),
194+
typeof(UILabel),
195+
typeof(UIAnchor),
196+
typeof(UIAtlas),
197+
typeof(UIFont),
198+
typeof(UITexture),
199+
typeof(UISprite),
200+
typeof(UIGrid),
201+
typeof(UITable),
202+
typeof(UIWrapGrid),
203+
typeof(UIInput),
204+
typeof(UIScrollView),
205+
typeof(UIEventListener),
206+
typeof(UIScrollBar),
207+
typeof(UICenterOnChild),
208+
typeof(UIScrollView),
209+
typeof(UIButton),
210+
typeof(UITextList),
211+
typeof(UIPlayTween),
212+
typeof(UIDragScrollView),
213+
typeof(UISpriteAnimation),
214+
typeof(UIWrapContent),
215+
typeof(TweenWidth),
216+
typeof(TweenAlpha),
217+
typeof(TweenColor),
218+
typeof(TweenRotation),
219+
typeof(TweenPosition),
220+
typeof(TweenScale),
221+
typeof(TweenHeight),
222+
typeof(TypewriterEffect),
223+
typeof(UIToggle),
224+
typeof(Localization),*/
225+
};
226+
227+
public static BindType _GT(Type t)
228+
{
229+
return new BindType(t);
230+
}
231+
232+
public static DelegateType _DT(Type t)
233+
{
234+
return new DelegateType(t);
235+
}
236+
237+
238+
[MenuItem("Lua/Attach Profiler", false, 151)]
239+
static void AttachProfiler()
240+
{
241+
if (!Application.isPlaying)
242+
{
243+
EditorUtility.DisplayDialog("警告", "请在运行时执行此功能", "确定");
244+
return;
245+
}
246+
247+
LuaClient.Instance.AttachProfiler();
248+
}
249+
250+
[MenuItem("Lua/Detach Profiler", false, 152)]
251+
static void DetachProfiler()
252+
{
253+
if (!Application.isPlaying)
254+
{
255+
return;
256+
}
257+
258+
LuaClient.Instance.DetachProfiler();
259+
}
260+
}

Assets/ToLua/Editor/Custom/CustomSettings.cs.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/ToLua/Plugins.meta

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/ToLua/Plugins/Android.meta

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/ToLua/Plugins/Android/libs.meta

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/ToLua/Plugins/Android/libs/arm64-v8a.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
652 KB
Binary file not shown.

Assets/ToLua/Plugins/Android/libs/arm64-v8a/libtolua.so.meta

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)