CustomSettings.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. using System;
  2. using System.Collections.Generic;
  3. using LuaInterface;
  4. using UnityEditor;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. using BindType = ToLuaMenu.BindType;
  8. using System.Reflection;
  9. public static class CustomSettings
  10. {
  11. public static string saveDir = Application.dataPath + "/ToLua/Source/Generate/";
  12. public static string toluaBaseType = Application.dataPath + "/ToLua/BaseType/";
  13. public static string baseLuaDir = Application.dataPath + "/Tolua/Lua/";
  14. public static string injectionFilesPath = Application.dataPath + "/ToLua/Injection/";
  15. //导出时强制做为静态类的类型(注意customTypeList 还要添加这个类型才能导出)
  16. //unity 有些类作为sealed class, 其实完全等价于静态类
  17. public static List<Type> staticClassTypes = new List<Type> {
  18. typeof (UnityEngine.Application),
  19. typeof (UnityEngine.Time),
  20. typeof (UnityEngine.Screen),
  21. typeof (UnityEngine.SleepTimeout),
  22. typeof (UnityEngine.Input),
  23. typeof (UnityEngine.Resources),
  24. typeof (UnityEngine.Physics),
  25. typeof (UnityEngine.RenderSettings),
  26. typeof (UnityEngine.QualitySettings),
  27. typeof (UnityEngine.GL),
  28. typeof (UnityEngine.Graphics),
  29. };
  30. //附加导出委托类型(在导出委托时, customTypeList 中牵扯的委托类型都会导出, 无需写在这里)
  31. public static DelegateType[] customDelegateList = {
  32. _DT (typeof (Action)),
  33. _DT (typeof (UnityEngine.Events.UnityAction)),
  34. _DT (typeof (System.Predicate<int>)),
  35. _DT (typeof (System.Action<int>)),
  36. _DT (typeof (System.Comparison<int>)),
  37. _DT (typeof (System.Func<int, int>)),
  38. };
  39. //在这里添加你要导出注册到lua的类型列表
  40. public static BindType[] customTypeList = {
  41. //------------------------为例子导出--------------------------------
  42. //_GT(typeof(TestEventListener)),
  43. //_GT(typeof(TestProtol)),
  44. //_GT(typeof(TestAccount)),
  45. //_GT(typeof(Dictionary<int, TestAccount>)).SetLibName("AccountMap"),
  46. //_GT(typeof(KeyValuePair<int, TestAccount>)),
  47. //_GT(typeof(Dictionary<int, TestAccount>.KeyCollection)),
  48. //_GT(typeof(Dictionary<int, TestAccount>.ValueCollection)),
  49. //_GT(typeof(TestExport)),
  50. //_GT(typeof(TestExport.Space)),
  51. //-------------------------------------------------------------------
  52. _GT (typeof(Dictionary<object, object>)),
  53. _GT (typeof (LuaInjectionStation)),
  54. _GT (typeof (InjectType)),
  55. _GT (typeof (Debugger)).SetNameSpace (null),
  56. //#if USING_DOTWEENING
  57. _GT (typeof (DG.Tweening.DOTween)),
  58. _GT (typeof (DG.Tweening.Ease)),
  59. _GT (typeof (DG.Tweening.Tween)).SetBaseType (typeof (System.Object)).AddExtendType (typeof (DG.Tweening.TweenExtensions)),
  60. _GT (typeof (DG.Tweening.Sequence)).AddExtendType (typeof (DG.Tweening.TweenSettingsExtensions)),
  61. _GT (typeof (DG.Tweening.Tweener)).AddExtendType (typeof (DG.Tweening.TweenSettingsExtensions)),
  62. _GT (typeof (DG.Tweening.LoopType)),
  63. _GT (typeof (DG.Tweening.PathMode)),
  64. _GT (typeof (DG.Tweening.PathType)),
  65. _GT (typeof (DG.Tweening.RotateMode)),
  66. _GT (typeof (Component)).AddExtendType (typeof (DG.Tweening.ShortcutExtensions)),
  67. _GT (typeof (Transform)).AddExtendType (typeof (DG.Tweening.ShortcutExtensions)).AddExtendType(typeof(UnityEngineUtils)),
  68. _GT (typeof (Light)).AddExtendType (typeof (DG.Tweening.ShortcutExtensions)),
  69. _GT (typeof (Material)).AddExtendType (typeof (DG.Tweening.ShortcutExtensions)),
  70. _GT (typeof (Rigidbody)).AddExtendType (typeof (DG.Tweening.ShortcutExtensions)),
  71. _GT (typeof (Camera)).AddExtendType (typeof (DG.Tweening.ShortcutExtensions)),
  72. _GT (typeof (AudioSource)).AddExtendType (typeof (DG.Tweening.ShortcutExtensions)),
  73. _GT (typeof (Graphic)).AddExtendType (typeof (DG.Tweening.DOTweenModuleUI)),
  74. //_GT(typeof(LineRenderer)).AddExtendType(typeof(DG.Tweening.ShortcutExtensions)),
  75. //_GT(typeof(TrailRenderer)).AddExtendType(typeof(DG.Tweening.ShortcutExtensions)),
  76. //#else
  77. //_GT(typeof(Component)).AddExtendType(typeof(UnityEngineUtils)),
  78. //_GT(typeof(Transform)).AddExtendType(typeof(UnityEngineUtils)),
  79. //_GT(typeof(Material)),
  80. //_GT(typeof(Light)),
  81. //_GT(typeof(Rigidbody)),
  82. //_GT(typeof(Camera)),
  83. //_GT(typeof(AudioSource)),
  84. //_GT(typeof(LineRenderer))
  85. //_GT(typeof(TrailRenderer))
  86. //#endif
  87. _GT (typeof (Behaviour)),
  88. _GT (typeof (MonoBehaviour)),
  89. _GT (typeof (GameObject)).AddExtendType (typeof (UnityEngineUtils)),
  90. _GT (typeof (TrackedReference)),
  91. _GT (typeof (Application)),
  92. _GT (typeof (Physics)),
  93. _GT (typeof (Collider)),
  94. _GT (typeof (Time)),
  95. _GT (typeof (Texture)),
  96. _GT (typeof (Texture2D)),
  97. // _GT(typeof(SkinWeights)),
  98. _GT(typeof(CanvasRenderer)),
  99. _GT (typeof (Shader)),
  100. _GT (typeof (Renderer)),
  101. _GT (typeof (WWW)),
  102. _GT (typeof (Screen)),
  103. _GT (typeof (CameraClearFlags)),
  104. _GT (typeof (AudioClip)),
  105. _GT (typeof (AssetBundle)),
  106. _GT (typeof (ParticleSystem)),
  107. _GT (typeof (AsyncOperation)).SetBaseType (typeof (System.Object)),
  108. _GT (typeof (LightType)),
  109. _GT (typeof (SleepTimeout)),
  110. #if UNITY_5_3_OR_NEWER && !UNITY_5_6_OR_NEWER
  111. _GT (typeof (UnityEngine.Experimental.Director.DirectorPlayer)),
  112. #endif
  113. _GT (typeof (Animator)),
  114. _GT (typeof (AnimatorStateInfo)),
  115. _GT (typeof (RuntimeAnimatorController)),
  116. _GT (typeof (AnimatorOverrideController)),
  117. _GT (typeof (Input)),
  118. _GT (typeof (KeyCode)),
  119. _GT (typeof (SkinnedMeshRenderer)),
  120. _GT (typeof (Space)),
  121. _GT (typeof (MeshRenderer)),
  122. #if !UNITY_5_4_OR_NEWER
  123. _GT (typeof (ParticleEmitter)),
  124. _GT (typeof (ParticleRenderer)),
  125. _GT (typeof (ParticleAnimator)),
  126. #endif
  127. _GT (typeof (BoxCollider)),
  128. _GT (typeof (MeshCollider)),
  129. _GT (typeof (SphereCollider)),
  130. _GT (typeof (CharacterController)),
  131. _GT (typeof (CapsuleCollider)),
  132. _GT (typeof (Animation)),
  133. _GT (typeof (AnimationClip)).SetBaseType (typeof (UnityEngine.Object)),
  134. _GT (typeof (AnimationState)),
  135. _GT (typeof (AnimationBlendMode)),
  136. _GT (typeof (QueueMode)),
  137. _GT (typeof (PlayMode)),
  138. _GT (typeof (WrapMode)),
  139. _GT (typeof (QualitySettings)),
  140. _GT (typeof (RenderSettings)),
  141. _GT (typeof (SkinWeights)),
  142. _GT (typeof (RenderTexture)),
  143. _GT (typeof (RenderTextureDescriptor)),
  144. _GT (typeof (RenderTextureFormat)),
  145. _GT (typeof (Resources)),
  146. _GT (typeof (LuaProfiler)),
  147. //关联类
  148. _GT (typeof (Image)).AddExtendType (typeof (DG.Tweening.DOTweenModuleUI)),
  149. _GT (typeof (RectTransform)).AddExtendType (typeof (DG.Tweening.DOTweenModuleUI)),
  150. _GT (typeof (RectTransform.Axis)),
  151. _GT (typeof (Button)),
  152. _GT (typeof (Button.ButtonClickedEvent)),
  153. _GT (typeof (Text)).AddExtendType (typeof (DG.Tweening.DOTweenModuleUI)),
  154. _GT (typeof (RawImage)),
  155. _GT (typeof (Toggle)),
  156. _GT (typeof (Toggle.ToggleEvent)),
  157. _GT (typeof (Slider)).AddExtendType (typeof (DG.Tweening.DOTweenModuleUI)),
  158. _GT (typeof (Slider.SliderEvent)),
  159. _GT (typeof (InputField)).AddExtendType (typeof (UnityEngineUtils)),
  160. _GT (typeof (InputField.OnChangeEvent)),
  161. _GT (typeof (InputField.SubmitEvent)),
  162. _GT (typeof (ScrollRect)).AddExtendType (typeof (DG.Tweening.DOTweenModuleUI)),
  163. _GT (typeof (ScrollRect.ScrollRectEvent)),
  164. _GT (typeof (Canvas)),
  165. _GT (typeof (CanvasGroup)).AddExtendType (typeof (DG.Tweening.DOTweenModuleUI)),
  166. //_GT(typeof(DG.Tweening.DOTween)),
  167. _GT (typeof (LayerMask)),
  168. _GT (typeof (Dropdown)),
  169. _GT (typeof (Dropdown.OptionData)),
  170. _GT (typeof (LayoutElement)),
  171. _GT (typeof (GridLayoutGroup)),
  172. _GT (typeof (VerticalLayoutGroup)),
  173. _GT (typeof (HorizontalLayoutGroup)),
  174. _GT (typeof (MeshFilter)),
  175. _GT (typeof (Int32)),
  176. _GT (typeof (PlayerPrefs)),
  177. _GT (typeof (ToggleGroup)),
  178. _GT (typeof (Quaternion)),
  179. _GT (typeof (Scrollbar)),
  180. //
  181. _GT (typeof (GameMgr)),
  182. _GT (typeof (Constants)),
  183. _GT (typeof (LuaConst)),
  184. _GT (typeof (LuaUIBase)),
  185. _GT (typeof (LuaMgr)),
  186. _GT (typeof (ResourceMgr)),
  187. _GT (typeof (ELoadType)),
  188. _GT (typeof (NetworkMgr)),
  189. _GT (typeof (ECoreEventType)),
  190. _GT (typeof (SceneMgr)),
  191. _GT (typeof (MusicMgr)),
  192. _GT (typeof (UIMgr)),
  193. _GT (typeof (DebugHelper)),
  194. _GT (typeof (TimerManager)),
  195. _GT (typeof (LoopVerticalScrollRect)),
  196. _GT (typeof (LoopHorizontalScrollRect)),
  197. _GT (typeof (FileUtils)),
  198. _GT (typeof (RepeatButton)),
  199. _GT (typeof (CheckInputLength)),
  200. _GT (typeof (GlobalConfig)),
  201. _GT (typeof (ModelMgr)),
  202. _GT (typeof (StoryCMType)),
  203. _GT (typeof (ActorDataMgr)),
  204. _GT (typeof (ActorData)),
  205. _GT (typeof (HeroActorData)),
  206. _GT (typeof (FellowActorData)),
  207. _GT (typeof (PetActorData)),
  208. _GT (typeof (LuaBattleBridge)),
  209. _GT (typeof (CUIPolygon)),
  210. _GT (typeof (TMPro.TextMeshProUGUI)),
  211. _GT (typeof (TMPro.TextMeshPro)),
  212. _GT (typeof (TMPro.TMP_InputField)),
  213. _GT (typeof (TMPro.TMP_TextUtilities)),
  214. _GT (typeof (TMPro.TMP_TextInfo)),
  215. _GT (typeof (TMPro.TMP_LinkInfo)),
  216. _GT (typeof (StringUtil)),
  217. _GT (typeof (UILocalizeScript)),
  218. _GT (typeof (ButtonTriggerAnimation)),
  219. _GT (typeof (UIEventHandler)),
  220. _GT (typeof (UIJoystick)),
  221. _GT (typeof (UIJoystick.OnDragEvent)),
  222. _GT (typeof (Cinemachine.CinemachineVirtualCamera)),
  223. _GT (typeof (UIEventTriggerListener)),
  224. _GT (typeof (UnityEngine.EventSystems.PointerEventData)),
  225. _GT (typeof (UnityEngine.EventSystems.PhysicsRaycaster)),
  226. _GT (typeof (LuaUInt64)),
  227. _GT (typeof (LuaUInt32)),
  228. _GT (typeof (ProfessionType)),
  229. _GT (typeof (I18N)),
  230. _GT (typeof (UIDragItem)),
  231. _GT (typeof (MirrorCamera)),
  232. _GT (typeof (CameraMgr)),
  233. _GT (typeof (SuperScrollView.LoopGridView)),
  234. _GT (typeof (SuperScrollView.LoopGridViewItem)),
  235. _GT (typeof (SuperScrollView.LoopGridViewSettingParam)),
  236. _GT (typeof (SuperScrollView.LoopGridViewInitParam)),
  237. _GT (typeof (SuperScrollView.RowColumnPair)),
  238. _GT (typeof (SuperScrollView.LoopListView)),
  239. _GT (typeof (SuperScrollView.LoopListViewItem)),
  240. _GT (typeof (SuperScrollView.LoopListViewInitParam)),
  241. _GT (typeof (SuperScrollView.GridFixedType)),
  242. _GT (typeof (UIExtensions.UIParticle)),
  243. _GT (typeof (DateTimeUtil)),
  244. _GT (typeof (PreviewCameraEvent)),
  245. _GT (typeof (AroundSphereMove)),
  246. _GT (typeof (RollingNumberText)),
  247. _GT (typeof (Rect)),
  248. _GT (typeof (RectOffset)),
  249. _GT (typeof (RenderingPath)),
  250. _GT (typeof (BattleSubMode)),
  251. _GT (typeof (BattleMode)),
  252. _GT (typeof (SceneType)),
  253. _GT (typeof (SkillParam)),
  254. _GT (typeof (BuffParam)),
  255. _GT (typeof (ActorParam)),
  256. _GT (typeof (FashionParam)),
  257. _GT (typeof (HairColorParam)),
  258. _GT (typeof (BodyPartParam)),
  259. _GT (typeof (ServerFighterParam)),
  260. _GT (typeof (GvGMark)),
  261. _GT (typeof (RO.ReorderableList)),
  262. _GT (typeof (RO.ReorderableList.ReorderableListEventStruct)),
  263. _GT (typeof (RO.ReorderableList.ReorderableListHandler)),
  264. _GT (typeof (SlideHorizontalLayoutGroup)),
  265. _GT (typeof (CastSkillData)),
  266. _GT (typeof (SwitchSprite)),
  267. _GT (typeof (LoopScrollRectDragEventInherit)),
  268. _GT (typeof (SlideVerticalLayoutGroup)),
  269. _GT (typeof (SlideGridLayoutGroup)),
  270. _GT (typeof (ContentSizeFitter)),
  271. _GT (typeof (WXB.SymbolText)),
  272. _GT (typeof (eNetType)),
  273. _GT (typeof (UIBigMapLine)),
  274. _GT (typeof (UIRaycastNoDraw)),
  275. _GT (typeof (UIGridViewMark)),
  276. _GT (typeof (UIPlayVideo)),
  277. _GT (typeof (AnimControlSkin)),
  278. _GT (typeof (GuideMask)),
  279. _GT (typeof (DropDownHelper)),
  280. _GT (typeof (WXB.SymbolTextEvent)),
  281. _GT (typeof (UIEffectCfg)),
  282. _GT (typeof (SInt)),
  283. _GT (typeof (SBool)),
  284. _GT (typeof (SFloat)),
  285. _GT (typeof (SDouble)),
  286. _GT (typeof (SLong)),
  287. _GT (typeof (SDataUtil)),
  288. _GT (typeof (OutputType)),
  289. _GT (typeof (OutputInfo)),
  290. _GT (typeof(BattleStatistics)),
  291. _GT (typeof(FighterStatistics)),
  292. _GT (typeof(SkillStatistics)),
  293. _GT (typeof(AvatarRTMgr)),
  294. _GT (typeof(BattleEndCondition)),
  295. _GT (typeof(ValType)),
  296. _GT (typeof(Spine.Unity.SkeletonGraphic)),
  297. _GT (typeof(Spine.AnimationState)),
  298. _GT (typeof(Spine.Skeleton)),
  299. _GT (typeof(TextAnchor)),
  300. _GT (typeof(SDKMgr)),
  301. _GT (typeof(ChannelType)),
  302. _GT (typeof(SDKModulType)),
  303. _GT (typeof(DeviceSystemData)),
  304. _GT (typeof(GameRoleInfo)),
  305. // _GT (typeof(Wenting.Lebian.LeBianSDK)),
  306. //_GT (typeof(Wenting.Lebian.QueryUpdateErrorCode)),
  307. _GT (typeof(UIImageSwitchSprite)),
  308. _GT (typeof (RolRectTransform)),
  309. _GT (typeof (UiLoopAutoMove)),
  310. _GT (typeof(GUIUtility)),
  311. _GT (typeof(UnityEngineUtils)),
  312. _GT (typeof(Vuplex.WebView.Web)),
  313. _GT (typeof(Vuplex.WebView.WebViewOptions)),
  314. _GT (typeof(Vuplex.WebView.WebPluginType)),
  315. _GT (typeof(Vuplex.WebView.WentingCanvasWebVewPrefab)),
  316. _GT (typeof(Vuplex.WebView.CanvasWebViewPrefab)),
  317. _GT (typeof(Vuplex.WebView.WebViewPrefab)),
  318. _GT (typeof(Vuplex.WebView.BaseWebViewPrefab)),
  319. _GT (typeof(Vuplex.WebView.DragMode)),
  320. _GT (typeof(Vuplex.WebView.BaseWebView)),
  321. _GT (typeof(Vuplex.WebView.ConsoleMessageEventArgs)),
  322. _GT (typeof(Vuplex.WebView.FocusedInputFieldChangedEventArgs)),
  323. _GT (typeof(Vuplex.WebView.ProgressChangedEventArgs)),
  324. _GT (typeof(Vuplex.WebView.UrlChangedEventArgs)),
  325. _GT (typeof(Vuplex.WebView.ScrolledEventArgs)),
  326. _GT (typeof(Vuplex.WebView.CanvasKeyboard)),
  327. _GT (typeof(Vuplex.WebView.Keyboard)),
  328. _GT (typeof(Vuplex.WebView.BaseKeyboard)),
  329. _GT (typeof(Vuplex.WebView.KeyModifier)),
  330. };
  331. public static List<Type> dynamicList = new List<Type>() {
  332. typeof (MeshRenderer),
  333. #if !UNITY_5_4_OR_NEWER
  334. typeof (ParticleEmitter),
  335. typeof (ParticleRenderer),
  336. typeof (ParticleAnimator),
  337. #endif
  338. typeof (BoxCollider),
  339. typeof (MeshCollider),
  340. typeof (SphereCollider),
  341. typeof (CharacterController),
  342. typeof (CapsuleCollider),
  343. typeof (Animation),
  344. typeof (AnimationClip),
  345. typeof (AnimationState),
  346. typeof (SkinWeights),
  347. typeof (RenderTexture),
  348. typeof (Rigidbody),
  349. };
  350. //重载函数,相同参数个数,相同位置out参数匹配出问题时, 需要强制匹配解决
  351. //使用方法参见例子14
  352. public static List<Type> outList = new List<Type>()
  353. {
  354. };
  355. //ngui优化,下面的类没有派生类,可以作为sealed class
  356. public static List<Type> sealedList = new List<Type>() { };
  357. public static BindType _GT(Type t)
  358. {
  359. return new BindType(t);
  360. }
  361. public static DelegateType _DT(Type t)
  362. {
  363. return new DelegateType(t);
  364. }
  365. //[MenuItem("Lua/Attach Profiler", false, 151)]
  366. static void AttachProfiler()
  367. {
  368. if (!Application.isPlaying)
  369. {
  370. EditorUtility.DisplayDialog("警告", "请在运行时执行此功能", "确定");
  371. return;
  372. }
  373. LuaClient.Instance.AttachProfiler();
  374. }
  375. //[MenuItem("Lua/Detach Profiler", false, 152)]
  376. static void DetachProfiler()
  377. {
  378. if (!Application.isPlaying)
  379. {
  380. return;
  381. }
  382. LuaClient.Instance.DetachProfiler();
  383. }
  384. }