public static void GenerateClassWraps() { if (!beAutoGen && EditorApplication.isCompiling) { EditorUtility.DisplayDialog("警告", "请等待编辑器完成编译再执行此功能", "确定"); return; } if (!File.Exists(CustomSettings.saveDir)) { Directory.CreateDirectory(CustomSettings.saveDir); } allTypes.Clear(); BindType[] typeList = CustomSettings.customTypeList; BindType[] list = GenBindTypes(typeList); ToLuaExport.allTypes.AddRange(baseType); for (int i = 0; i < list.Length; i++) { ToLuaExport.allTypes.Add(list[i].type); } for (int i = 0; i < list.Length; i++) { ToLuaExport.Clear(); ToLuaExport.className = list[i].name; ToLuaExport.type = list[i].type; ToLuaExport.isStaticClass = list[i].IsStatic; ToLuaExport.baseType = list[i].baseType; ToLuaExport.wrapClassName = list[i].wrapName; ToLuaExport.libClassName = list[i].libName; ToLuaExport.extendList = list[i].extendList; ToLuaExport.Generate(CustomSettings.saveDir); } Debug.Log("Generate lua binding files over"); ToLuaExport.allTypes.Clear(); allTypes.Clear(); AssetDatabase.Refresh(); }
static void GenBaseTypeLuaWrap() { if (!beAutoGen && EditorApplication.isCompiling) { EditorUtility.DisplayDialog("警告", "请等待编辑器完成编译在执行此功能", "确定"); return; } string dir = Application.dataPath + "/ToLua/BaseType/"; if (!File.Exists(dir)) { Directory.CreateDirectory(dir); } allTypes.Clear(); List <BindType> btList = new List <BindType>(); for (int i = 0; i < baseType.Count; i++) { btList.Add(new BindType(baseType[i])); } GenBindTypes(btList.ToArray(), false); BindType[] list = allTypes.ToArray(); for (int i = 0; i < list.Length; i++) { ToLuaExport.Clear(); ToLuaExport.className = list[i].name; ToLuaExport.type = list[i].type; ToLuaExport.isStaticClass = list[i].IsStatic; ToLuaExport.baseType = list[i].baseType; ToLuaExport.wrapClassName = list[i].wrapName; ToLuaExport.libClassName = list[i].libName; ToLuaExport.Generate(dir); } Debug.Log("Generate base type files over"); allTypes.Clear(); AssetDatabase.Refresh(); }
public static void Binding() { if (!Application.isPlaying) { EditorApplication.isPlaying = true; } BindType[] list = WrapFile.binds; for (int i = 0; i < list.Length; i++) { ToLuaExport.Clear(); ToLuaExport.className = list[i].name; ToLuaExport.type = list[i].type; ToLuaExport.isStaticClass = list[i].IsStatic; ToLuaExport.baseClassName = list[i].baseName; ToLuaExport.wrapClassName = list[i].wrapName; ToLuaExport.libClassName = list[i].libName; ToLuaExport.Generate(null); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < list.Length; i++) { sb.AppendFormat("\t\t{0}Wrap.Register();\r\n", list[i].wrapName); } EditorApplication.isPlaying = false; //StringBuilder sb1 = new StringBuilder(); //for (int i = 0; i < binds.Length; i++) //{ // sb1.AppendFormat("\t\t{0}Wrap.Register(L);\r\n", binds[i].wrapName); //} GenLuaBinder(); GenLuaDelegates(); Debug.Log("Generate lua binding files over"); AssetDatabase.Refresh(); }
public static void BindingCustom() { BindType[] list = WrapFile.CustomBinds; if (list.Length <= 0) { EditorUtility.DisplayDialog("", "WrapaFile/CustomBinds里面没有文件,请添加文件后再生成wrap", "确定"); return; } String msg = String.Format("CustomBinds包含 {0} 等在内一共 {1} 个文件,是否确定生成Wrap?", list[0].name, list.Length); if (EditorUtility.DisplayDialog("生成Wrap", msg, "确定", "取消")) { if (!Application.isPlaying) { EditorApplication.isPlaying = true; } for (int i = 0; i < list.Length; i++) { ToLuaExport.Clear(); ToLuaExport.className = list[i].name; ToLuaExport.type = list[i].type; ToLuaExport.isStaticClass = list[i].IsStatic; ToLuaExport.baseClassName = list[i].baseName; ToLuaExport.wrapClassName = list[i].wrapName; ToLuaExport.libClassName = list[i].libName; ToLuaExport.Generate(null); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < list.Length; i++) { sb.AppendFormat("\t\t{0}Wrap.Register();\r\n", list[i].wrapName); } EditorApplication.isPlaying = false; AssetDatabase.Refresh(); } }
public static void Binding() { if (!Check()) { return; } BindType[] list = binds; for (int i = 0; i < list.Length; i++) { ToLuaExport.Clear(); ToLuaExport.className = list[i].name; ToLuaExport.type = list[i].type; ToLuaExport.isStaticClass = list[i].IsStatic; ToLuaExport.baseClassName = list[i].baseName; ToLuaExport.wrapClassName = list[i].wrapName; ToLuaExport.libClassName = list[i].libName; ToLuaExport.wrapAllMethods = list[i].Is2WrapAllMethods; ToLuaExport.methodsFilter = list[i].wrapMethods; ToLuaExport.wrapAllFields = list[i].Is2WrapAllFields; ToLuaExport.fieldsFilter = list[i].wrapFields; ToLuaExport.Generate(null); } StringBuilder sb = new StringBuilder(); for (int i = 0; i < list.Length; i++) { sb.AppendFormat("\t\t{0}Wrap.Register();\r\n", list[i].wrapName); } EditorApplication.isPlaying = false; GenLuaBinder(); GenTypeIDMap(); Debug.Log("Generate lua binding files over"); AssetDatabase.Refresh(); }
public static void Binding() { BindType[] list = WrapFile.getBinds(); for (int i = 0; i < list.Length; i++) { ToLuaExport.Clear(); ToLuaExport.className = list[i].name; ToLuaExport.type = list[i].type; ToLuaExport.isStaticClass = list[i].IsStatic; ToLuaExport.baseClassName = list[i].baseName; ToLuaExport.wrapClassName = list[i].wrapName; ToLuaExport.libClassName = list[i].libName; ToLuaExport.Generate(null); } GenLuaBinder(); // 暂不需要生成委托工厂 //GenLuaDelegates(); Debug.Log("Generate lua binding files over"); AssetDatabase.Refresh(); }
public static void U3dBinding() { List <string> dropList = new List <string> { //特殊修改 "UnityEngine.Object", //一般情况不需要的类, 编辑器相关的 "HideInInspector", "ExecuteInEditMode", "AddComponentMenu", "ContextMenu", "RequireComponent", "DisallowMultipleComponent", "SerializeField", "AssemblyIsEditorAssembly", "Attribute", //一些列文件,都是编辑器相关的 "FFTWindow", "Types", "UnitySurrogateSelector", "TypeInferenceRules", "ThreadPriority", "Debug", //自定义debugger取代 "GenericStack", //异常,lua无法catch "PlayerPrefsException", "UnassignedReferenceException", "UnityException", "MissingComponentException", "MissingReferenceException", //RPC网络 "RPC", "Network", "MasterServer", "BitStream", "HostData", "ConnectionTesterStatus", //unity 自带编辑器GUI "GUI", "EventType", "EventModifiers", //"Event", "FontStyle", "TextAlignment", "TextEditor", "TextEditorDblClickSnapping", "TextGenerator", "TextClipping", "TextGenerationSettings", "TextAnchor", "TextAsset", "TextWrapMode", "Gizmos", "ImagePosition", "FocusType", //地形相关 "Terrain", "Tree", "SplatPrototype", "DetailPrototype", "DetailRenderMode", //其他 "MeshSubsetCombineUtility", "AOT", "Random", "Mathf", "Social", "Enumerator", "SendMouseEvents", "Cursor", "Flash", "ActionScript", //非通用的类 "ADBannerView", "ADInterstitialAd", "Android", "jvalue", "iPhone", "iOS", "CalendarIdentifier", "CalendarUnit", "CalendarUnit", "FullScreenMovieControlMode", "FullScreenMovieScalingMode", "Handheld", "LocalNotification", "Motion", //空类 "NotificationServices", "RemoteNotificationType", "RemoteNotification", "SamsungTV", "TextureCompressionQuality", "TouchScreenKeyboardType", "TouchScreenKeyboard", "MovieTexture", //我不需要的 //2d 类 "AccelerationEventWrap", //加速 "AnimatorUtility", "AudioChorusFilter", "AudioDistortionFilter", "AudioEchoFilter", "AudioHighPassFilter", "AudioLowPassFilter", "AudioReverbFilter", "AudioReverbPreset", "AudioReverbZone", "AudioRolloffMode", "AudioSettings", "AudioSpeakerMode", "AudioType", "AudioVelocityUpdateMode", "Ping", "Profiler", "StaticBatchingUtility", "Font", "Gyroscope", //不需要重力感应 "ISerializationCallbackReceiver", //u3d 继承的序列化接口,lua不需要 "ImageEffectOpaque", //后处理 "ImageEffectTransformsToLDR", "PrimitiveType", // 暂时不需要 GameObject.CreatePrimitive "Skybox", //不会u3d自带的Skybox "SparseTexture", // mega texture 不需要 "Plane", "PlayerPrefs", //不用ugui "SpriteAlignment", "SpriteMeshType", "SpritePackingMode", "SpritePackingRotation", "SpriteRenderer", "Sprite", "UIVertex", "CanvasGroup", "CanvasRenderer", "ICanvasRaycastFilter", "Canvas", "RectTransform", "DrivenRectTransformTracker", "DrivenTransformProperties", "RectTransformAxis", "RectTransformEdge", "RectTransformUtility", "RectTransform", "UICharInfo", "UILineInfo", //不需要轮子碰撞体 "WheelCollider", "WheelFrictionCurve", "WheelHit", //手机不适用雾 "FogMode", "UnityEventBase", "UnityEventCallState", "UnityEvent", "LightProbeGroup", "LightProbes", "NPOTSupport", //只是SystemInfo 的一个枚举值 //没用到substance纹理 "ProceduralCacheSize", "ProceduralLoadingBehavior", "ProceduralMaterial", "ProceduralOutputType", "ProceduralProcessorUsage", "ProceduralPropertyDescription", "ProceduralPropertyType", "ProceduralTexture", //物理关节系统 "JointDriveMode", "JointDrive", "JointLimits", "JointMotor", "JointProjectionMode", "JointSpring", "SoftJointLimit", "SpringJoint", "HingeJoint", "FixedJoint", "ConfigurableJoint", "CharacterJoint", "Joint", "LODGroup", "LOD", "DataUtility", //给sprite使用的 "CrashReport", "CombineInstance", }; List <BindType> list = new List <BindType>(); Assembly assembly = Assembly.Load("UnityEngine"); Type[] types = assembly.GetExportedTypes(); for (int i = 0; i < types.Length; i++) { //不导出: 模版类,event委托, c#协同相关, obsolete 类 if (!types[i].IsGenericType && types[i].BaseType != typeof(System.MulticastDelegate) && !typeof(YieldInstruction).IsAssignableFrom(types[i]) && !ToLuaExport.IsObsolete(types[i])) { list.Add(_GT(types[i])); } else { Debug.Log("drop generic type " + types[i].ToString()); } } for (int i = 0; i < dropList.Count; i++) { list.RemoveAll((p) => { return(p.type.ToString().Contains(dropList[i])); }); } //for (int i = 0; i < list.Count; i++) //{ // if (!typeof(UnityEngine.Object).IsAssignableFrom(list[i].type) && !list[i].type.IsEnum && !typeof(UnityEngine.TrackedReference).IsAssignableFrom(list[i].type) // && !list[i].type.IsValueType && !list[i].type.IsSealed) // { // Debug.Log(list[i].type.Name); // } //} for (int i = 0; i < list.Count; i++) { try { ToLuaExport.Clear(); ToLuaExport.className = list[i].name; ToLuaExport.type = list[i].type; ToLuaExport.isStaticClass = list[i].IsStatic; ToLuaExport.baseClassName = list[i].baseName; ToLuaExport.wrapClassName = list[i].wrapName; ToLuaExport.libClassName = list[i].libName; ToLuaExport.Generate(null); } catch (Exception e) { Debug.LogWarning("Generate wrap file error: " + e.ToString()); } } GenLuaBinder(); Debug.Log("Generate lua binding files over, Generate " + list.Count + " files"); AssetDatabase.Refresh(); }