using System; using System.Collections.Generic; using XLua; using System.Reflection; using System.Collections; using UnityEngine; public static class LuaGen { [LuaCallCSharp] public static List LuaCallCSharp = new List() { typeof(UnityEngine.Video.VideoPlayer.EventHandler), typeof(Action), typeof(DateTime), typeof(Dictionary), typeof(Dictionary), typeof(Dictionary), typeof(Dictionary), typeof(Dictionary), typeof(Dictionary.Enumerator), typeof(IEnumerator), typeof(KeyValuePair), typeof(List), typeof(List), typeof(List), typeof(LuaEnv), typeof(object), typeof(System.Net.Dns), typeof(System.Net.Sockets.AddressFamily), typeof(System.Net.Sockets.SocketError), typeof(System.Runtime.CompilerServices.ExtensionAttribute), typeof(TimeSpan), typeof(Convert), typeof(UnityEngine.NetworkReachability), typeof(UnityEngine.AI.NavMeshAgent), typeof(UnityEngine.AI.NavMeshObstacle), typeof(UnityEngine.AnimationClip), typeof(UnityEngine.AnimationCurve), typeof(UnityEngine.Animator), typeof(UnityEngine.AnimatorStateInfo), typeof(UnityEngine.Application), typeof(UnityEngine.Behaviour), typeof(UnityEngine.Bounds), typeof(UnityEngine.BoxCollider), typeof(UnityEngine.Camera), typeof(UnityEngine.Camera.MonoOrStereoscopicEye), typeof(UnityEngine.Camera.StereoscopicEye), typeof(UnityEngine.Rendering.Universal.CameraExtensions), typeof(UnityEngine.Rendering.Universal.UniversalAdditionalCameraData), //typeof(Cinemachine.CinemachineBrain), //typeof(Cinemachine.CinemachineVirtualCamera), //typeof(Cinemachine.LensSettings), typeof(UnityEngine.Canvas), typeof(UnityEngine.CanvasGroup), typeof(UnityEngine.Collider), typeof(UnityEngine.Color), typeof(UnityEngine.ColorUtility), typeof(UnityEngine.Component), typeof(UnityEngine.Debug), typeof(UnityEngine.Events.UnityEvent), typeof(UnityEngine.EventSystems.BaseEventData), typeof(UnityEngine.EventSystems.PhysicsRaycaster), typeof(UnityEngine.EventSystems.PointerEventData), typeof(UnityEngine.EventSystems.PointerEventData.FramePressState), typeof(UnityEngine.EventSystems.PointerEventData.InputButton), typeof(UnityEngine.EventSystems.UIBehaviour), typeof(UnityEngine.GameObject), typeof(UnityEngine.GUIUtility), typeof(UnityEngine.Input), typeof(UnityEngine.Keyframe), typeof(UnityEngine.LayerMask), typeof(UnityEngine.LineRenderer), typeof(UnityEngine.Material), typeof(UnityEngine.Mathf), typeof(UnityEngine.Matrix4x4), typeof(UnityEngine.MonoBehaviour), typeof(UnityEngine.Networking.DownloadHandler), typeof(UnityEngine.Networking.DownloadHandlerBuffer), typeof(UnityEngine.Networking.DownloadHandlerTexture), typeof(UnityEngine.Networking.UnityWebRequest), typeof(UnityEngine.Networking.UnityWebRequestAsyncOperation), typeof(UnityEngine.Object), typeof(UnityEngine.ParticleSystem), typeof(UnityEngine.ParticleSystem.MainModule), typeof(UnityEngine.Playables.PlayableDirector), typeof(UnityEngine.PlayerPrefs), typeof(UnityEngine.Quaternion), typeof(UnityEngine.Random), typeof(UnityEngine.Ray), typeof(UnityEngine.Ray2D), typeof(UnityEngine.RaycastHit), typeof(UnityEngine.Rect), typeof(UnityEngine.RectTransform), typeof(UnityEngine.RectTransform.Axis), typeof(UnityEngine.RectTransform.Edge), typeof(UnityEngine.RectTransformUtility), typeof(UnityEngine.Renderer), typeof(UnityEngine.RenderTexture), typeof(UnityEngine.Resources), typeof(UnityEngine.Rigidbody), typeof(UnityEngine.RuntimeAnimatorController), typeof(UnityEngine.RuntimePlatform), typeof(UnityEngine.Screen), typeof(UnityEngine.SleepTimeout), typeof(UnityEngine.SkinnedMeshRenderer), typeof(UnityEngine.Sprite), typeof(UnityEngine.SystemInfo), typeof(UnityEngine.TextAsset), typeof(UnityEngine.Texture), typeof(UnityEngine.Texture2D), typeof(UnityEngine.ImageConversion), typeof(UnityEngine.Texture2D.EXRFlags), typeof(UnityEngine.Time), typeof(UnityEngine.TouchPhase), typeof(UnityEngine.Transform), typeof(UnityEngine.GameObject), typeof(UnityEngine.UI.Button), typeof(UnityEngine.UI.Button.ButtonClickedEvent), typeof(UnityEngine.UI.Dropdown), typeof(UnityEngine.UI.GridLayoutGroup), typeof(UnityEngine.UI.GridLayoutGroup.Axis), typeof(UnityEngine.UI.GridLayoutGroup.Constraint), typeof(UnityEngine.UI.GridLayoutGroup.Corner), typeof(UnityEngine.UI.HorizontalLayoutGroup), typeof(UnityEngine.UI.Image), typeof(UnityEngine.UI.Image.FillMethod), typeof(UnityEngine.UI.Image.Origin180), typeof(UnityEngine.UI.Image.Origin360), typeof(UnityEngine.UI.Image.Origin360), typeof(UnityEngine.UI.Image.Origin90), typeof(UnityEngine.UI.Image.OriginHorizontal), typeof(UnityEngine.UI.Image.OriginVertical), typeof(UnityEngine.UI.Image.Type), typeof(UnityEngine.UI.InputField), typeof(UnityEngine.UI.InputField.CharacterValidation), typeof(UnityEngine.UI.InputField.ContentType), typeof(UnityEngine.UI.InputField.InputType), typeof(UnityEngine.UI.InputField.LineType), typeof(UnityEngine.UI.InputField.OnChangeEvent), typeof(UnityEngine.UI.InputField.SubmitEvent), typeof(UnityEngine.UI.InputField.OnValidateInput), typeof(UnityEngine.UI.LayoutGroup), typeof(UnityEngine.UI.LayoutRebuilder), typeof(UnityEngine.UI.MaskableGraphic), typeof(UnityEngine.UI.MaskableGraphic.CullStateChangedEvent), typeof(UnityEngine.UI.RawImage), typeof(UnityEngine.UI.Scrollbar), typeof(UnityEngine.UI.Scrollbar.Direction), typeof(UnityEngine.UI.Scrollbar.ScrollEvent), typeof(UnityEngine.UI.ScrollRect), typeof(UnityEngine.UI.ScrollRect.MovementType), typeof(UnityEngine.UI.ScrollRect.ScrollbarVisibility), typeof(UnityEngine.UI.ScrollRect.ScrollRectEvent), typeof(UnityEngine.UI.Selectable), typeof(UnityEngine.UI.Selectable.Transition), typeof(UnityEngine.UI.Slider), typeof(UnityEngine.UI.Slider.Direction), typeof(UnityEngine.UI.Slider.SliderEvent), typeof(UnityEngine.UI.Text), typeof(UnityEngine.UI.Toggle), typeof(UnityEngine.UI.Toggle.ToggleEvent), typeof(UnityEngine.UI.Toggle.ToggleTransition), typeof(UnityEngine.UI.CanvasScaler), typeof(UnityEngine.Vector2), typeof(UnityEngine.Vector2Int), typeof(UnityEngine.Vector3), typeof(UnityEngine.Vector3Int), typeof(List), typeof(UnityEngine.Vector4), typeof(UnityEngine.WaitForEndOfFrame), typeof(UnityEngine.TextMesh), typeof(UnityEngine.Profiling.Profiler), typeof(XGame.XWebSocket), typeof(XGame.lsocket), typeof(UnityEngine.Timeline.ActivationTrack), typeof(UnityEngine.Timeline.ControlTrack), typeof(UnityEngine.Timeline.ControlPlayableAsset), typeof(UnityEngine.Video.VideoPlayer), typeof(UnityEngine.LayerMask), typeof(Action), typeof(Func), typeof(Action), typeof(Func), typeof(TimeZoneInfo), typeof(DayOfWeek), typeof(DG.Tweening.ShortcutExtensions), typeof(DG.Tweening.TweenExtensions), typeof(DG.Tweening.TweenSettingsExtensions), typeof(DG.Tweening.Ease), typeof(DG.Tweening.RotateMode), //typeof(DG.Tweening.Tween), typeof(DG.Tweening.DOTween), typeof(DG.Tweening.DOTweenModuleUI), //typeof(XGame.Utility), #if DEVELOPMENT || RELEASE typeof(GYGame.GMToolViewBuilder), typeof(MobileConsole.UI.GenericNodeView), typeof(MobileConsole.UI.CheckboxNodeView), typeof(MobileConsole.UI.DropdownNodeView), typeof(MobileConsole.UI.InputNodeView), typeof(MobileConsole.UI.SliderNodeView), typeof(MobileConsole.UI.CategoryNodeView), #endif }; [GCOptimize] public static List GCOptimizeList = new List() { }; [CSharpCallLua] public static List CSharpCallLua = new List() { typeof(IEnumerator), typeof(UnityEngine.Events.UnityAction), typeof(UnityEngine.Events.UnityAction), typeof(UnityEngine.Events.UnityAction), typeof(UnityEngine.Events.UnityAction), typeof(UnityEngine.Events.UnityAction), typeof(UnityEngine.Events.UnityAction), typeof(UnityEngine.LayerMask), typeof(UnityEngine.EventSystems.PhysicsRaycaster), typeof(Action), typeof(Action), typeof(Action), typeof(Action), typeof(Action), typeof(Action), typeof(Action), typeof(Action), typeof(UnityEngine.Events.UnityAction), typeof(UnityEngine.Events.UnityAction), typeof(UnityEngine.Events.UnityAction), typeof(UnityEngine.UI.InputField.OnValidateInput), typeof(Action), typeof(Action), typeof(Action), typeof(Action), typeof(Action), typeof(Action), typeof(Action), typeof(Action), typeof(Action), typeof(Action), typeof(Action), typeof(Action), typeof(Func>), typeof(Func), typeof(Func), typeof(Func), typeof(Func), typeof(Func), typeof(Func), typeof(Func), typeof(Action), typeof(Action), typeof(Action>), typeof(Func), typeof(Func), typeof(Func), typeof(Action), typeof(Func), typeof(Action>), typeof(Action), typeof(Action), typeof(UnityEngine.EventSystems.PointerEventData), typeof(Func), typeof(Action), typeof(Action), typeof(Action), typeof(DG.Tweening.Core.DOGetter), typeof(DG.Tweening.Core.DOGetter), typeof(DG.Tweening.Core.DOGetter), typeof(DG.Tweening.Core.DOGetter), typeof(DG.Tweening.Core.DOSetter), typeof(DG.Tweening.Core.DOSetter), #if DEVELOPMENT || RELEASE typeof(MobileConsole.UI.GenericNodeView.Callback), typeof(MobileConsole.UI.CheckboxNodeView.Callback), typeof(MobileConsole.UI.DropdownNodeView.Callback), typeof(MobileConsole.UI.InputNodeView.Callback), typeof(MobileConsole.UI.SliderNodeView.Callback), #endif }; private static Type[] Elements = { typeof(bool), typeof(int), typeof(float), typeof(double), typeof(string), typeof(object) }; private static List GetElementsList() { List list1= new List(); //List list1 = XGame.Utility.GetPermutation(Elements, 3); //List list2 = XGame.Utility.GetPermutation(Elements, 2); //list1.AddRange(list2); //for (int i = 0; i < Elements.Length; i++) //{ // Type e = Elements[i]; // list1.Add(new[] // { // e // }); // list1.Add(new[] // { // e, // e // }); // list1.Add(new[] // { // e, // e, // e // }); //} //for (int i = 0; i < list2.Count; ++i) //{ // Type[] elements = list2[i]; // Type e1 = elements[0]; // Type e2 = elements[1]; // list1.Add(new[] // { // e1, // e1, // e2 // }); // list1.Add(new[] // { // e1, // e2, // e1 // }); // list1.Add(new[] // { // e2, // e1, // e1 // }); //} return list1; } private static List GetCSharpCallLua() { List list = GetElementsList(); List csharpCallLua = new List(); for (int i = 0; i < list.Count; ++i) { Type[] elements = list[i]; Type actionGeneric = null; Type funcGeneric = null; switch (elements.Length) { case 1: actionGeneric = typeof(Action<>); funcGeneric = typeof(Func<>); break; case 2: actionGeneric = typeof(Action<,>); funcGeneric = typeof(Func<,>); break; case 3: actionGeneric = typeof(Action<,,>); funcGeneric = typeof(Func<,,>); break; } if (actionGeneric != null) { csharpCallLua.Add(actionGeneric.MakeGenericType(elements)); } if (funcGeneric != null) { csharpCallLua.Add(funcGeneric.MakeGenericType(elements)); } } return csharpCallLua; } [CSharpCallLua] public static List CSharpCallLuaAuto = GetCSharpCallLua(); [BlackList] public static List> BlackList = new List>() { new List() { "UnityEngine.Texture2D", "alphaIsTransparency" }, new List() { "UnityEngine.Security", "GetChainOfTrustValue" }, new List() { "UnityEngine.CanvasRenderer", "onRequestRebuild" }, new List() { "UnityEngine.Light", "areaSize" }, new List() { "UnityEngine.AnimatorOverrideController", "PerformOverrideClipListCleanup" }, #if !UNITY_WEBPLAYER new List() { "UnityEngine.Application", "ExternalEval" }, #endif new List() { "UnityEngine.GameObject", "networkView" }, new List() { "UnityEngine.Component", "networkView" }, new List() { "System.IO.FileInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections" }, new List() { "System.IO.FileInfo", "SetAccessControl", "System.Security.AccessControl.FileSecurity" }, new List() { "System.IO.DirectoryInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections" }, new List() { "System.IO.DirectoryInfo", "SetAccessControl", "System.Security.AccessControl.DirectorySecurity" }, new List() { "System.IO.DirectoryInfo", "CreateSubdirectory", "System.String", "System.Security.AccessControl.DirectorySecurity" }, new List() { "System.IO.DirectoryInfo", "Create", "System.Security.AccessControl.DirectorySecurity" }, new List() { "UnityEngine.MonoBehaviour", "runInEditMode" }, new List() { "UnityEngine.Input", "IsJoystickPreconfigured", "System.String" }, new List() { "UnityEngine.Texture", "imageContentsHash" }, new List() { "UnityEngine.UI.Text", "OnRebuildRequested" }, new List() { "XGame.Actor", "RidToActorDict" }, new List() { "XGame.Actor", "GetInspectedData", "XGame.PropertyInspectorBehaviour" }, new List() { "XGame.Utility", "GetBuildPlatformName", "UnityEditor.BuildTarget" }, new List() { "XGame.FileManager", "OnFileChange", "System.Object", "System.IO.FileSystemEventArgs", }, new List() { "XGame.FileManager", "OnFileRename", "System.Object", "System.IO.RenamedEventArgs", }, new List() { "XGame.FileManager", "OnFileError", "System.Object", "System.IO.ErrorEventArgs", }, new List(){ "UnityEngine.Material", "IsChildOf", "UnityEngine.Material"}, new List(){ "UnityEngine.Material", "RevertAllPropertyOverrides"}, new List(){ "UnityEngine.Material", "IsPropertyOverriden", "System.Int32"}, new List(){ "UnityEngine.Material", "IsPropertyOverriden", "System.String"}, new List(){ "UnityEngine.Material", "IsPropertyLocked", "System.Int32"}, new List(){ "UnityEngine.Material", "IsPropertyLocked", "System.String"}, new List(){ "UnityEngine.Material", "IsPropertyLockedByAncestor", "System.Int32"}, new List(){ "UnityEngine.Material", "IsPropertyLockedByAncestor", "System.String"}, new List(){ "UnityEngine.Material", "SetPropertyLock","System.Int32", "System.Boolean"}, new List(){ "UnityEngine.Material", "SetPropertyLock", "System.String", "System.Boolean"}, new List(){ "UnityEngine.Material", "ApplyPropertyOverride","UnityEngine.Material", "System.String", "System.Boolean"}, new List(){ "UnityEngine.Material", "ApplyPropertyOverride","UnityEngine.Material", "System.Int32", "System.Boolean"}, new List(){ "UnityEngine.Material", "RevertPropertyOverride", "System.Int32"}, new List(){ "UnityEngine.Material", "RevertPropertyOverride", "System.String"}, new List(){ "UnityEngine.Material", "parent"}, new List(){ "UnityEngine.Material", "isVariant"}, new List() { "RenderHeads.Media.AVProVideo.MediaPlayer", "EditorUpdate" }, new List() { "RenderHeads.Media.AVProVideo.MediaPlayer", "CheckEditorAudioMute" }, new List() { "RenderHeads.Media.AVProVideo.MediaPlayer", "EditorAllPlayersDispose" }, new List() { "RenderHeads.Media.AVProVideo.MediaPlayer", "GetPlatformOptions", "RenderHeads.Media.AVProVideo.Platform" }, new List() { "RenderHeads.Media.AVProVideo.MediaPlayer", "GetPlatformOptionsVariable", "RenderHeads.Media.AVProVideo.Platform" }, new List() { "RenderHeads.Media.AVProVideo.MediaPlayer", "SaveFrameToExr" }, new List() { "RenderHeads.Media.AVProVideo.MediaPlayer", "SaveFrameToPng" }, new List() { "RenderHeads.Media.AVProVideo.MediaPlayer", "InternalMediaLoadedEvent" }, new List() { "UnityEngine.MonoBehaviour", "EnableScriptReloadInCheckConsistency", "System.Boolean"}, }; #if UNITY_2018_1_OR_NEWER [BlackList] public static Func MethodFilter = (memberInfo) => { if (memberInfo.DeclaringType.IsGenericType && memberInfo.DeclaringType.GetGenericTypeDefinition() == typeof(Dictionary<,>)) { if (memberInfo.MemberType == MemberTypes.Constructor) { ConstructorInfo constructorInfo = memberInfo as ConstructorInfo; ParameterInfo[] parameterInfos = constructorInfo.GetParameters(); if (parameterInfos.Length > 0) { if (typeof(IEnumerable).IsAssignableFrom(parameterInfos[0].ParameterType)) { return true; } } } else if (memberInfo.MemberType == MemberTypes.Method) { MethodInfo methodInfo = memberInfo as MethodInfo; if (methodInfo.Name == "TryAdd" || methodInfo.Name == "Remove" && methodInfo.GetParameters().Length == 2) { return true; } } } if (memberInfo.DeclaringType.IsGenericType && memberInfo.DeclaringType.GetGenericTypeDefinition() == typeof(KeyValuePair<,>)) { if (memberInfo.MemberType == MemberTypes.Method) { MethodInfo methodInfo = memberInfo as MethodInfo; if (methodInfo.Name == "Deconstruct") { return true; } } } if (memberInfo.MemberType == MemberTypes.Method) { MethodInfo methodInfo = memberInfo as MethodInfo; ParameterInfo[] parameterInfos = methodInfo.GetParameters(); foreach (ParameterInfo param in parameterInfos) { if (typeof(ReadOnlySpan).IsAssignableFrom(param.ParameterType) || typeof(ReadOnlySpan).IsAssignableFrom(param.ParameterType) || typeof(ReadOnlySpan).IsAssignableFrom(param.ParameterType) || typeof(ReadOnlySpan).IsAssignableFrom(param.ParameterType) || typeof(Span).IsAssignableFrom(param.ParameterType) || typeof(Span).IsAssignableFrom(param.ParameterType) || typeof(Span).IsAssignableFrom(param.ParameterType) || typeof(Span).IsAssignableFrom(param.ParameterType) ) { return true; } } } return false; }; #endif }