From 67369b670340cf6369a96857555ca643c1acde36 Mon Sep 17 00:00:00 2001 From: lwb <q3213421wrwqr> Date: 星期四, 10 十二月 2020 16:12:51 +0800 Subject: [PATCH] 9527 一些快捷创建预制件的右键菜单,去掉luaide 版本管理 --- /dev/null | 7 - .gitignore | 2 Assets/Editor/Tool/PrefabCreateTool.cs | 193 +++++++++++++++++------------------------------ Assets/Editor/ScriptEditor/SecondFrameLoaderEditor.cs | 22 +++++ Assets/Editor/ScriptEditor/SecondFrameLoaderEditor.cs.meta | 5 5 files changed, 96 insertions(+), 133 deletions(-) diff --git a/.gitignore b/.gitignore index 1d1ccfc..0bc1a1a 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,5 @@ /Assets/Plugins/Android/bin.meta /Assets/Resources/VersionConfig.asset /Assets/XLua/Gen +/Assets/XLua/Src/Editor/LuaIde +/Assets/XLua/Src/Editor/LuaIde diff --git a/Assets/Editor/ScriptEditor/SecondFrameLoaderEditor.cs b/Assets/Editor/ScriptEditor/SecondFrameLoaderEditor.cs new file mode 100644 index 0000000..f81a9e3 --- /dev/null +++ b/Assets/Editor/ScriptEditor/SecondFrameLoaderEditor.cs @@ -0,0 +1,22 @@ + +using Snxxz.UI; +using UnityEditor; +using UnityEngine; + +[CustomEditor(typeof(SecondFrameLoader))] +public class SecondFrameLoaderEditor : Editor +{ + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + if (GUILayout.Button("閲嶈浇")) + { + Reload(); + } + } + + private void Reload() + { + (target as SecondFrameLoader).Reload(); + } +} diff --git a/Assets/XLua/Src/Editor/LuaIde/LuaIdeApi.cs.meta b/Assets/Editor/ScriptEditor/SecondFrameLoaderEditor.cs.meta similarity index 68% rename from Assets/XLua/Src/Editor/LuaIde/LuaIdeApi.cs.meta rename to Assets/Editor/ScriptEditor/SecondFrameLoaderEditor.cs.meta index 2e0cd0b..25a826b 100644 --- a/Assets/XLua/Src/Editor/LuaIde/LuaIdeApi.cs.meta +++ b/Assets/Editor/ScriptEditor/SecondFrameLoaderEditor.cs.meta @@ -1,8 +1,7 @@ fileFormatVersion: 2 -guid: 85cbb758da75d59489ff44f998c5b421 -timeCreated: 1503820513 -licenseType: Free +guid: bbbbef6ecc9236d40968ea8eab8da64a MonoImporter: + externalObjects: {} serializedVersion: 2 defaultReferences: [] executionOrder: 0 diff --git a/Assets/Editor/Tool/PrefabCreateTool.cs b/Assets/Editor/Tool/PrefabCreateTool.cs index 2fd9ee7..bfe36ba 100644 --- a/Assets/Editor/Tool/PrefabCreateTool.cs +++ b/Assets/Editor/Tool/PrefabCreateTool.cs @@ -11,23 +11,26 @@ public class PrefabCreateTool { - - [MenuItem("GameObject/UI/FunctionButton")] - public static void CreateFunctionButton() + [MenuItem("GameObject/UI/UIRoot")] + public static UIRoot CreateUIRoot() { - var instance = UIUtility.CreateWidget("FunctionButtonPattern", "FunctionButton"); - if (instance != null) + var uiroot = GameObject.FindObjectOfType<UIRoot>(); + if (uiroot == null) { - var uiroot = GameObject.FindObjectOfType<UIRoot>(); - if (uiroot == null) - { - var prefab = BuiltInLoader.LoadPrefab("UIRoot"); - var root = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity); - root.name = "UIRoot"; - uiroot = root.GetComponent<UIRoot>(); - } + var prefab = BuiltInLoader.LoadPrefab("UIRoot"); + var root = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.identity); + root.name = "UIRoot"; + uiroot = root.GetComponent<UIRoot>(); + } + return uiroot; + } - Transform parent = null; + public static void SetParent(GameObject instance, Transform parent = null) + { + if (instance == null) + return; + var uiroot = CreateUIRoot(); + if (parent == null) if (Selection.transforms != null && Selection.transforms.Length > 0) { parent = Selection.transforms[0]; @@ -36,12 +39,17 @@ { parent = uiroot.normalCanvas.transform; } + instance.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one); + // PrefabUtility.DisconnectPrefabInstance(instance); + Selection.activeGameObject = instance; + } - instance.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one); - PrefabUtility.DisconnectPrefabInstance(instance); - Selection.activeGameObject = instance; - } + [MenuItem("GameObject/UI/FunctionButton")] + public static void CreateFunctionButton() + { + var instance = UIUtility.CreateWidget("FunctionButtonPattern", "FunctionButton"); + SetParent(instance); } [MenuItem("GameObject/UI/GeneralWin_1")] @@ -50,32 +58,7 @@ var prefab = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Editor/UIPattern/GeneralWin.prefab"); var instance = GameObject.Instantiate(prefab) as GameObject; instance.name = "GeneralWin"; - - if (instance != null) - { - var uiroot = GameObject.FindObjectOfType<UIRoot>(); - if (uiroot == null) - { - var rootPrefab = BuiltInLoader.LoadPrefab("UIRoot"); - var root = GameObject.Instantiate(rootPrefab, Vector3.zero, Quaternion.identity); - root.name = "UIRoot"; - uiroot = root.GetComponent<UIRoot>(); - } - - Transform parent = null; - if (Selection.transforms != null && Selection.transforms.Length > 0) - { - parent = Selection.transforms[0]; - } - else - { - parent = uiroot.normalCanvas.transform; - } - - instance.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one); - PrefabUtility.DisconnectPrefabInstance(instance); - Selection.activeGameObject = instance; - } + SetParent(instance); } [MenuItem("GameObject/UI/RewardGroup")] @@ -84,32 +67,7 @@ var prefab = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Editor/UIPattern/Container_Rewards.prefab"); var instance = GameObject.Instantiate(prefab) as GameObject; instance.name = "Container_Rewards"; - - if (instance != null) - { - var uiroot = GameObject.FindObjectOfType<UIRoot>(); - if (uiroot == null) - { - var rootPrefab = BuiltInLoader.LoadPrefab("UIRoot"); - var root = GameObject.Instantiate(rootPrefab, Vector3.zero, Quaternion.identity); - root.name = "UIRoot"; - uiroot = root.GetComponent<UIRoot>(); - } - - Transform parent = null; - if (Selection.transforms != null && Selection.transforms.Length > 0) - { - parent = Selection.transforms[0]; - } - else - { - parent = uiroot.normalCanvas.transform; - } - - instance.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one); - PrefabUtility.DisconnectPrefabInstance(instance); - Selection.activeGameObject = instance; - } + SetParent(instance); } [MenuItem("GameObject/UI/CommonItemCell")] @@ -118,33 +76,7 @@ var prefab = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Editor/UIPattern/CommonItemCell.prefab"); var instance = GameObject.Instantiate(prefab) as GameObject; instance.name = "CommonItemCell"; - - if (instance != null) - { - var uiroot = GameObject.FindObjectOfType<UIRoot>(); - if (uiroot == null) - { - var rootPrefab = BuiltInLoader.LoadPrefab("UIRoot"); - var root = GameObject.Instantiate(rootPrefab, Vector3.zero, Quaternion.identity); - root.name = "UIRoot"; - uiroot = root.GetComponent<UIRoot>(); - } - - Transform parent = null; - if (Selection.transforms != null && Selection.transforms.Length > 0) - { - parent = Selection.transforms[0]; - } - else - { - parent = uiroot.normalCanvas.transform; - } - - instance.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one); - PrefabUtility.DisconnectPrefabInstance(instance); - Selection.activeGameObject = instance; - } - + SetParent(instance); } [MenuItem("GameObject/UI/SortTable")] @@ -153,33 +85,48 @@ var prefab = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Editor/UIPattern/SortTable.prefab"); var instance = GameObject.Instantiate(prefab) as GameObject; instance.name = "SortTable"; - - if (instance != null) - { - var uiroot = GameObject.FindObjectOfType<UIRoot>(); - if (uiroot == null) - { - var rootPrefab = BuiltInLoader.LoadPrefab("UIRoot"); - var root = GameObject.Instantiate(rootPrefab, Vector3.zero, Quaternion.identity); - root.name = "UIRoot"; - uiroot = root.GetComponent<UIRoot>(); - } - - Transform parent = null; - if (Selection.transforms != null && Selection.transforms.Length > 0) - { - parent = Selection.transforms[0]; - } - else - { - parent = uiroot.normalCanvas.transform; - } - - instance.transform.SetParentEx(parent, Vector3.zero, Quaternion.identity, Vector3.one); - PrefabUtility.DisconnectPrefabInstance(instance); - Selection.activeGameObject = instance; - } + SetParent(instance); } + + [MenuItem("GameObject/UI/TextEx")] + public static void CreateTextEx() + { + var instance = new GameObject("TextEx"); + instance.AddComponent<TextEx>(); + SetParent(instance); + } + + [MenuItem("GameObject/UI/ImageEx")] + public static void CreateImageEx() + { + var instance = new GameObject("ImageEx"); + instance.AddComponent<ImageEx>(); + SetParent(instance); + } + + [MenuItem("GameObject/UI/ButtonEx")] + public static void CreateButtonEx() + { + var button = new GameObject("ButtonEx"); + var btnEx = button.AddComponent<ButtonEx>(); + var imgEx = button.AddComponent<ImageEx>(); + btnEx.targetGraphic = imgEx; + SetParent(button); + var text = new GameObject("TextEx"); + text.AddComponent<TextEx>(); + SetParent(text, button.transform); + } + + [MenuItem("GameObject/UI/SecondFrameLoader")] + public static void CreateSecondFrameLoader() + { + var go = new GameObject("SecondFrameLoader"); + go.AddComponent<SecondFrameLoader>(); + SetParent(go); + } + + + } diff --git a/Assets/XLua/Src/Editor/LuaIde/LuaIdeApi.cs b/Assets/XLua/Src/Editor/LuaIde/LuaIdeApi.cs deleted file mode 100644 index cd8150a..0000000 --- a/Assets/XLua/Src/Editor/LuaIde/LuaIdeApi.cs +++ /dev/null @@ -1,395 +0,0 @@ -锘� -using CSObjectWrapEditor; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Text; -using UnityEditor; -using UnityEngine; -using XLua; - -namespace Assets.XLua.Src.Editor.LuaIde -{ - [InitializeOnLoad] - public class LuaIdeApi - { - public TextAsset Template; - static List<Type> LuaCallCSharp; - - static List<Type> CSharpCallLua; - - static List<Type> GCOptimizeList; - - static Dictionary<Type, List<string>> AdditionalProperties; - - static List<Type> ReflectionUse; - - static List<List<string>> BlackList; - - - - static Dictionary<Type, OptimizeFlag> OptimizeCfg; - static IEnumerable<Type> type_has_extension_methods = null; - - static LuaIdeApi() { - GenLinkXml(); - } - private static string GetConfigPath() - { - string[] assets = AssetDatabase.GetAllAssetPaths(); - string config = null; - foreach (string asset in assets) - { - if (asset.EndsWith("luaIdeConfig.txt")) - { - config = asset; - } - } - - return config; - } - [MenuItem("LuaIde/璁剧疆瀵煎嚭璺緞", false, 1)] - public static void ExportPath() - { - - string config =GetConfigPath(); - if (config != null) - { - Selection.activeObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(config); - } - else - { - EditorUtility.DisplayDialog("luaide", "娌℃湁鎵惧埌luaideConfig.txt.璇烽噸鏂颁笅杞絣uaIde api瀵煎嚭鎻掍欢!", "ok"); - - } - - - } - [MenuItem("LuaIde/LuaIde Api", false, 1)] - public static void GenLinkXml() - { - - Generator.CustomGen(Application.dataPath + "/Xlua/Src/Editor/LuaIde/LuaIdeApi.tpl.txt", GetTasks); - } - public static LuaIdeInfo addLuaIdeInfo(Type type){ - - LuaIdeInfo.luaInfo = new LuaIdeInfo(); - string fullName = type.FullName; - if (fullName.IndexOf('`') > -1 && fullName.IndexOf("]]") > -1){ - //灏嗚繖娈典俊鎭埅鍙栨帀 - return null; - - } - LuaIdeInfo.luaInfo.tableName = fullName; - - if (LuaIdeInfo.luaInfo.tableName.IndexOf('+') > -1) - { - - LuaIdeInfo.luaInfo.tableName = LuaIdeInfo.luaInfo.tableName.Replace('+', '.'); - } - if (type.BaseType != null) - { - bool isAdd = true; - LuaIdeInfo.luaInfo.baseName = LuaIdeInfo.getTypeStr(type.BaseType, out isAdd); - - - } - - LuaIdeInfo.luaInfo.tableName = "CS." + LuaIdeInfo.luaInfo.tableName; - - - List<MethodInfo> methods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.DeclaredOnly) - .Where(method => !method.IsDefined(typeof(ExtensionAttribute), true) || method.DeclaringType != type) - .Where(method => !isMethodInBlackList(method) &&(!method.IsGenericMethod)).ToList(); - LuaIdeInfo.luaInfo.methods = methods; - - List<PropertyInfo> ps = type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.DeclaredOnly) - .Where(prop => prop.Name != "Item" && !isObsolete(prop) && !isMemberInBlackList(prop)).ToList(); - foreach (PropertyInfo p in ps) { - LuaIdeInfo.luaInfo.addVar(new LuaIdeVarInfo() - { - propertyInfo = p, - isget = p.CanRead, - isset = p.CanWrite - }); - } - List<FieldInfo> fs = type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.IgnoreCase | BindingFlags.DeclaredOnly) - .Where(field => !isObsolete(field) && !isMemberInBlackList(field)).ToList(); - foreach (FieldInfo f in fs) - { - string value = ""; - if (type.IsEnum) { - if (f.Name != "value__") - { - value = Convert.ToInt32(f.GetValue(null)).ToString(); - } - else { - continue; - } - - } - LuaIdeInfo.luaInfo.addVar(new LuaIdeVarInfo() - { - fieldInfo = f, - isget =true, - isset = true, - value = value - }); - } - - LuaIdeInfo.luaInfo.ctorList = type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase).ToList(); - LuaIdeInfo.luaInfos.Add(LuaIdeInfo.luaInfo); - return LuaIdeInfo.luaInfo; - - - - } - - static IEnumerable<MethodInfo> GetExtensionMethods(Type extendedType) - { - if (type_has_extension_methods == null) - { - var gen_types = LuaCallCSharp; - - type_has_extension_methods = from type in gen_types - where type.GetMethods(BindingFlags.Static | BindingFlags.Public) - .Any(method => isDefined(method, typeof(ExtensionAttribute))) - select type; - } - return from type in type_has_extension_methods - where type.IsSealed && !type.IsGenericType && !type.IsNested - from method in type.GetMethods(BindingFlags.Static | BindingFlags.Public) - where isSupportedExtensionMethod(method, extendedType) - select method; - } - static bool isDefined(MemberInfo test, Type type) - { -#if XLUA_GENERAL - return test.GetCustomAttributes(false).Any(ca => ca.GetType().ToString() == type.ToString()); -#else - return test.IsDefined(type, false); -#endif - } - static bool isSupportedExtensionMethod(MethodBase method, Type extendedType) - { - if (!isDefined(method, typeof(ExtensionAttribute))) - return false; - var methodParameters = method.GetParameters(); - if (methodParameters.Length < 1) - return false; - - var hasValidGenericParameter = false; - for (var i = 0; i < methodParameters.Length; i++) - { - var parameterType = methodParameters[i].ParameterType; - if (i == 0) - { - if (parameterType.IsGenericParameter) - { - var parameterConstraints = parameterType.GetGenericParameterConstraints(); - if (parameterConstraints.Length == 0) return false; - bool firstParamMatch = false; - foreach (var parameterConstraint in parameterConstraints) - { - if (parameterConstraint != typeof(ValueType) && parameterConstraint.IsAssignableFrom(extendedType)) - { - firstParamMatch = true; - } - } - if (!firstParamMatch) return false; - - hasValidGenericParameter = true; - } - else if (parameterType != extendedType) - return false; - } - else if (parameterType.IsGenericParameter) - { - var parameterConstraints = parameterType.GetGenericParameterConstraints(); - if (parameterConstraints.Length == 0) return false; - foreach (var parameterConstraint in parameterConstraints) - { - if (!parameterConstraint.IsClass || (parameterConstraint == typeof(ValueType)) || hasGenericParameter(parameterConstraint)) - return false; - } - hasValidGenericParameter = true; - } - } - return hasValidGenericParameter || !method.ContainsGenericParameters; - } - - static bool hasGenericParameter(Type type) - { - if (type.IsByRef || type.IsArray) - { - return hasGenericParameter(type.GetElementType()); - } - if (type.IsGenericType) - { - foreach (var typeArg in type.GetGenericArguments()) - { - if (hasGenericParameter(typeArg)) - { - return true; - } - } - return false; - } - return type.IsGenericParameter; - } - public static IEnumerable<CustomGenTask> GetTasks(LuaEnv lua_env, UserConfig user_cfg) - { - LuaIdeClassDoc.checkDoc(); - LuaIdeInfo.luaInfos = new List<LuaIdeInfo>(); - LuaCallCSharp = user_cfg.LuaCallCSharp.ToList();// Generator.LuaCallCSharp; - CSharpCallLua = user_cfg.CSharpCallLua.ToList();// Generator.CSharpCallLua; - BlackList = Generator.BlackList; - foreach (Type type in LuaCallCSharp) { - - LuaIdeInfo luaInfo = addLuaIdeInfo(type); - if (luaInfo != null) { - List<MethodInfo> mo = GetExtensionMethods(type).ToList(); - luaInfo.methods.AddRange(mo); - } - - } - - - StringBuilder luasb = new StringBuilder(); - foreach (LuaIdeInfo luainfo in LuaIdeInfo.luaInfos) - { - - if (luainfo.tableName != null) - { - if (luainfo.tableName != null) - { - if (luainfo.tableName.IndexOf("System.Collections.Generic.List") > -1) - continue; - if (luainfo.tableName.IndexOf("System.Collections.Generic.Dictionary") > -1) - continue; - - luasb.AppendLine(luainfo.toStr()); - } - - } - - } - DirectoryInfo dirinfo = new DirectoryInfo(Application.dataPath); - string exportConfig = GetConfigPath(); - string dir = dirinfo.FullName + "/luaIde/"; - if (exportConfig != null) - { - string[] lines = File.ReadAllLines(exportConfig); - - foreach (string line in lines) - { - - string lineStr = line.Trim(); - if(lineStr.Length > 0) - { - lineStr = lineStr.Replace("\\","/"); - if(lineStr[0] != '#') - { - - lineStr = Path.Combine(Application.dataPath, lineStr); - lineStr = lineStr.Replace("\\", "/"); - - if (!Directory.Exists(lineStr)) - { - - EditorUtility.DisplayDialog("luaIdeConfig.txt涓嶅瓨鍦�", "璺緞:" + lineStr + "涓嶅瓨鍦ㄨ閲嶆柊閰嶇疆luaIdeConfig.txt", "ok"); - ExportPath(); - } - else - { - if(lineStr[lineStr.Length - 1] == '/') - { - lineStr = lineStr.Substring(0, lineStr.Length - 1); - } - dir = lineStr + "/luaIde/"; - } - break; - } - } - } - } - - if (!Directory.Exists(dir)) - { - Directory.CreateDirectory(dir); - } - string filename = dir + "xluaApi.lua"; - using (StreamWriter textWriter = new StreamWriter(filename, false, Encoding.UTF8)) - { - textWriter.Write(luasb.ToString()); - textWriter.Flush(); - textWriter.Close(); - } - - LuaTable data = lua_env.NewTable(); - List<string> dd = new List<string>(); - - Debug.Log("luaApi鍒涘缓鎴愬姛," + filename); - data.Set("infos",dd); - yield return new CustomGenTask - { - Data = data, - Output = new StreamWriter(dir + "/readMe", - false, Encoding.UTF8) - }; - } - - static bool isObsolete(MemberInfo mb) - { - if (mb == null) return false; - return mb.IsDefined(typeof(System.ObsoleteAttribute), false); - } - - static bool isMemberInBlackList(MemberInfo mb) - { - if (mb.IsDefined(typeof(BlackListAttribute), false)) return true; - - foreach (var exclude in BlackList) - { - if (mb.DeclaringType.FullName == exclude[0] && mb.Name == exclude[1]) - { - return true; - } - } - - return false; - } - - static bool isMethodInBlackList(MethodBase mb) - { - if (mb.IsDefined(typeof(BlackListAttribute), false)) return true; - - foreach (var exclude in BlackList) - { - if (mb.DeclaringType.FullName == exclude[0] && mb.Name == exclude[1]) - { - var parameters = mb.GetParameters(); - if (parameters.Length != exclude.Count - 2) - { - continue; - } - bool paramsMatch = true; - - for (int i = 0; i < parameters.Length; i++) - { - if (parameters[i].ParameterType.FullName != exclude[i + 2]) - { - paramsMatch = false; - break; - } - } - if (paramsMatch) return true; - } - } - return false; - } - } -} diff --git a/Assets/XLua/Src/Editor/LuaIde/LuaIdeApi.tpl.txt b/Assets/XLua/Src/Editor/LuaIde/LuaIdeApi.tpl.txt deleted file mode 100644 index 06141b1..0000000 --- a/Assets/XLua/Src/Editor/LuaIde/LuaIdeApi.tpl.txt +++ /dev/null @@ -1,3 +0,0 @@ -锘�<%ForEachCsList(infos, function(info)%> - -<%end)%> diff --git a/Assets/XLua/Src/Editor/LuaIde/LuaIdeApi.tpl.txt.meta b/Assets/XLua/Src/Editor/LuaIde/LuaIdeApi.tpl.txt.meta deleted file mode 100644 index 7566293..0000000 --- a/Assets/XLua/Src/Editor/LuaIde/LuaIdeApi.tpl.txt.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: c407de03fd504474099525a987068719 -timeCreated: 1504024332 -licenseType: Free -TextScriptImporter: - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/XLua/Src/Editor/LuaIde/LuaIdeClassDoc.cs b/Assets/XLua/Src/Editor/LuaIde/LuaIdeClassDoc.cs deleted file mode 100644 index e0f6b03..0000000 --- a/Assets/XLua/Src/Editor/LuaIde/LuaIdeClassDoc.cs +++ /dev/null @@ -1,145 +0,0 @@ -锘縰sing System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Xml; -using UnityEngine; - - - public class LuaIdeClassDocInfo{ - public string name; - public string doc; - public Dictionary<string,string> paraminfo = new Dictionary<string,string>(); - } - public class LuaIdeClassDoc - { - public static List<LuaIdeClassDocInfo> infos; - public static void checkDoc() - { - infos = new List<LuaIdeClassDocInfo>(); - - string path = Application.dataPath + "/doc.xml"; - - if (!File.Exists(path)) - { - return; - } - string xx = "1"; - - //鍒涘缓xml鏂囨。 - XmlDocument xml = new XmlDocument(); - XmlReaderSettings set = new XmlReaderSettings(); - set.IgnoreComments = true;//杩欎釜璁剧疆鏄拷鐣ml娉ㄩ噴鏂囨。鐨勫奖鍝嶃�傛湁鏃跺�欐敞閲婁細褰卞搷鍒皒ml鐨勮鍙� - xml.Load(XmlReader.Create((path), set)); - //寰楀埌objects鑺傜偣涓嬬殑鎵�鏈夊瓙鑺傜偣 - XmlNodeList xmlNodeList = xml.SelectSingleNode("doc").ChildNodes; - foreach (XmlElement xl1 in xmlNodeList) - { - if (xl1.Name == "members") - { - //缁х画閬嶅巻id涓�1鐨勮妭鐐逛笅鐨勫瓙鑺傜偣 - foreach(XmlElement xl2 in xl1.ChildNodes) - { - LuaIdeClassDocInfo info = new LuaIdeClassDocInfo(); - - string name = xl2.GetAttribute("name"); - - if (name.IndexOf(":") > -1) { - name = name.Split(':')[1]; - } - if (name.IndexOf('(') > -1) { - name = name.Split('(')[0]; - } - - info.name = name; - info.doc = ""; - - infos.Add(info); - try - { - foreach (XmlElement xl3 in xl2.ChildNodes) - { - if (xl3.Name == "summary") - { - string doc1 = ""; - string doc = xl3.InnerText.Trim(); - if (doc.IndexOf('\n') > -1) - { - string[] docs = doc.Split('\n'); - for(int i = 0;i < docs.Length;i++) - { - string str = docs[i]; - if (i == docs.Length - 1) - { - doc1 += "\t" + str.Trim() ; - } - else { - doc1 += "\t" + str.Trim() + "\n"; - } - - } - info.doc = doc1; - } - else { - info.doc = "\t"+ doc; - } - - } - else if (xl3.Name == "param") - { - string pdoc = xl3.InnerText.Trim(); - if (pdoc.IndexOf('\n') > -1) { - string[] pdocs = pdoc.Split('\n'); - pdoc = ""; - for (int i = 0; i < pdocs.Length; i++) - { - pdoc += pdocs[i].Trim() + " "; - } - - - } - info.paraminfo.Add(xl3.GetAttribute("name"), pdoc); - } - - } - } - catch (Exception e) - { - int ss = 1; - } - - } - - } - } - - - } - public static LuaIdeClassDocInfo getLuaIdeClassDocInfo(string key) - { - foreach (LuaIdeClassDocInfo info in infos) - { - if (info.name == key) - { - return info; - } - } - return null; - } - public static string getDoc(string key) - { - foreach(LuaIdeClassDocInfo info in infos){ - if(info.name == key){ - return info.doc; - } - } - return ""; - } - - - - - } - - diff --git a/Assets/XLua/Src/Editor/LuaIde/LuaIdeClassDoc.cs.meta b/Assets/XLua/Src/Editor/LuaIde/LuaIdeClassDoc.cs.meta deleted file mode 100644 index 4e3000d..0000000 --- a/Assets/XLua/Src/Editor/LuaIde/LuaIdeClassDoc.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 486cfad79a593e44eacac6d19f75e346 -timeCreated: 1503845858 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/XLua/Src/Editor/LuaIde/LuaIdeInfo.cs b/Assets/XLua/Src/Editor/LuaIde/LuaIdeInfo.cs deleted file mode 100644 index 267772d..0000000 --- a/Assets/XLua/Src/Editor/LuaIde/LuaIdeInfo.cs +++ /dev/null @@ -1,455 +0,0 @@ -锘� -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Linq; -using System.Reflection; -using System.Text; - - - - public class LuaIdeVarInfo{ - public FieldInfo fieldInfo; - public PropertyInfo propertyInfo; - public EventInfo eventInfo; - public string value=""; - - public bool isget= false; - public bool isset=false; - } - public class LuaIdeInfo - { - public static LuaIdeInfo luaInfo; - public static List<LuaIdeInfo> luaInfos = new List<LuaIdeInfo>(); - public string tableName; - public string baseName; - public bool IsEnum; - public bool isStaticClass; - public bool isNewFun = false; - public List<MethodInfo> methods; - public List<ConstructorInfo> ctorList; - public bool isDefConstructorInfo = false; - public List<LuaIdeVarInfo> varInfos = new List<LuaIdeVarInfo>(); - - - public List<string> events = new List<string>(); - - public void addVar(LuaIdeVarInfo varInfo) - { - varInfos.Add(varInfo); - } - - - public string toStr() { - - if (tableName.IndexOf("+") > -1) - { - tableName = tableName.Replace("+", "."); - } - StringBuilder sb = new StringBuilder(); - - if (IsEnum) - { - sb.AppendLine("--" + tableName + " Enum"); - } - else { - if (this.baseName != null) { - sb.AppendLine("--@SuperType [luaIde#" + this.baseName + "]"); - } - - - } - - sb.AppendLine(tableName + " = {}"); - if (this.isDefConstructorInfo) - { - string commenStr = "--[[\n"; - commenStr += "\t@return: [luaIde#" + tableName + "]\n"; - commenStr += "]]"; - sb.AppendLine("function " + tableName + ":() end"); - } - else - { - if (this.ctorList != null) - { - - foreach (ConstructorInfo info in this.ctorList) - { - - - string commenStr = "--[[\n"; - - ParameterInfo[] parameterInfos = info.GetParameters(); - string parstr = ""; - for (int i = 0; i < parameterInfos.Length; i++) - { - ParameterInfo param = parameterInfos[i]; - string paramStr = ""; - - if (param.Name == "end") - { - paramStr = param.Name + "_"; - } - else - { - paramStr = param.Name; - } - parstr += paramStr; - bool isadd = false; - paramStr = "\t@" + paramStr + " " + getTypeStr(param.ParameterType, out isadd); - paramStr += "\n"; - commenStr += paramStr; - if (i < parameterInfos.Length - 1) - { - parstr += ","; - - } - } - commenStr += "\t@return: [luaIde#" + tableName + "]\n"; - commenStr += "]]"; - sb.AppendLine(commenStr); - sb.AppendLine("function " + tableName + "(" + parstr + ") end"); - - } - } - } - //瀛楁 - List<string> propertyInfoFunName = new List<string>(); - foreach (LuaIdeVarInfo info in varInfos) - { - string varName = ""; - string commenStr = "--[[\n"; - Type type_ = null; - if (info.fieldInfo != null) - { - object[] obj = info.fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), true); - if (IsEnum && info.fieldInfo.Name == "value__") { - continue; - } - type_ = info.fieldInfo.FieldType; - varName = info.fieldInfo.Name; - } - else if (info.propertyInfo != null) { - type_ = info.propertyInfo.PropertyType; - varName = info.propertyInfo.Name; - propertyInfoFunName.Add("get_" + varName); - propertyInfoFunName.Add("set_" + varName); - } - else if (info.eventInfo != null) { - type_ = info.eventInfo.EventHandlerType; - varName = info.eventInfo.Name; - } - if (varName == "end") continue; - bool isadd = false; - string type__ = getTypeStr(type_, out isadd); - string typestr = ""; - if (isadd && !type_.IsEnum) - { - - typestr = "\t@RefType [luaIde#" + type__ + "]"; - } - else { - if (!IsEnum) - { - typestr = "\t" + type__; - } - } - - - - commenStr += typestr + "\n"; - if (info.isget) { - commenStr += "\t Get "; - } - if (info.isset) { - commenStr += "\t Set "; - } - string str = tableName + "." + varName; - string doc = LuaIdeClassDoc.getDoc(str); - - - if (info.value != "") - { - varName += " = " + info.value; - } - else { - varName += " = nil"; - } - sb.AppendLine(commenStr); - - if (doc != "") - { - sb.AppendLine( doc); - } - sb.AppendLine("--]]"); - sb.AppendLine(tableName + "."+varName); - - } - - - - //鏂规硶 - foreach (MethodInfo m in methods) { - - if (m.Name == "end") { - continue; - } - if (m.Name.IndexOf(".") > -1) - { - continue; - } - - if (m.Name.IndexOf("set_") == 0 || m.Name.IndexOf("get_") == 0) - { - continue; - } - string commenStr = "--[[\n"; - - LuaIdeClassDocInfo docInfo = LuaIdeClassDoc.getLuaIdeClassDocInfo(tableName + "." + m.Name); - if (docInfo != null && docInfo.doc != "") - { - commenStr += docInfo.doc + "\n"; - } - ParameterInfo[] parameterInfos = m.GetParameters(); - string parstr = ""; - for (int i = 0; i < parameterInfos.Length;i++ ) - { - ParameterInfo param = parameterInfos[i]; - string paramStr = ""; - - if (param.Name == "end") - { - paramStr = param.Name + "_"; - } - else - { - paramStr = param.Name; - } - parstr += paramStr; - bool isadd = false; - paramStr = "\t@" + paramStr + " " + getTypeStr(param.ParameterType,out isadd) ; - if (docInfo != null) - { - if (docInfo.paraminfo.ContainsKey(param.Name)) - { - paramStr +=docInfo.paraminfo[param.Name]+ "\n"; - } - else { - paramStr += "\n"; - } - - } - else - { - paramStr += "\n"; - } - - - commenStr += paramStr; - if (i < parameterInfos.Length - 1) - { - parstr += ","; - - } - } - - if (m.ReturnType != null && m.ReturnType.FullName != "System.Void") - { - bool isadd = false; - - string type__ = getTypeStr(m.ReturnType, out isadd); - if (isadd && !m.ReturnType.IsEnum) - { - commenStr += "\t@return: [luaIde#" + type__ + "]\n"; - } - else { - commenStr += "\t@return: "+ type__ + "\n"; - } - - } - commenStr += "--]]"; - if (parameterInfos.Length > 0 || (docInfo != null && docInfo.doc != "") || m.ReturnType == null && m.ReturnType.FullName == "System.Void") - { - sb.AppendLine(commenStr); - } - sb.AppendLine("function " + tableName + ":" + m.Name + "(" + parstr + ") end"); - } - return sb.ToString(); - - } - public static string GetDictionaryKeyValueType(Type type) - { - PropertyInfo[] pis = type.GetProperties(); - foreach (PropertyInfo pi in pis) - { - if (pi.Name == "Item") - { - MethodInfo method = pi.GetSetMethod(); - ParameterInfo[] parameter = method.GetParameters(); - if (parameter.Length == 2) - { - - if (parameter[0].ParameterType.FullName.IndexOf("[") > -1) { - return null; - } - if (parameter[1].ParameterType.FullName.IndexOf("[") > -1) - { - return null; - } - string typeStr = "CS."+parameter[0].ParameterType.FullName + ",luaIde#CS." + parameter[1].ParameterType.FullName; - return typeStr; - } - - } - } - return null; - } - public static string GetListItemType(Type type) - { - PropertyInfo[] pis = type.GetProperties(); - foreach (PropertyInfo pi in pis) - { - if (pi.Name == "Item") - { - MethodInfo method = pi.GetSetMethod(); - ParameterInfo[] parameter = method.GetParameters(); - if (parameter.Length == 2) - { - - if (parameter[0].ParameterType.FullName.IndexOf("[") > -1) - { - return null; - } - - - return parameter[1].ParameterType.FullName; - } - - } - } - return null; - } - public Type getNullableTypeStr(Type ptype) - { - - PropertyInfo[] pis = ptype.GetProperties(); - foreach (PropertyInfo pi in pis) - { - if (pi.Name == "Value") - { - MethodInfo method = pi.GetGetMethod(); - if (method != null) - { - return method.ReturnType; - } - - - } - } - return null; - } - public static string getTypeStr(Type type,out bool isadd) { - isadd = false; - - - Type tempType = Nullable.GetUnderlyingType(type); - if (tempType != null) { - type = tempType; - } - string type_ = type.FullName; - - - bool isArray = false; - if (type_ == null) - { - - type_ = type.FullName; - if (type_ == null) { type_ = ""; } - } - else { - if (typeof(IDictionary).IsAssignableFrom(type)) - { - type_ = GetDictionaryKeyValueType(type); - if (type_ != null) - { - isadd = true; - } - else - { - type_ = ""; - isadd = false; - } - return type_; - - } - - else if (type.IsArray) - { - - if (type_.EndsWith("[]")) - { - isArray = true; - type_ = type_.Substring(0, type_.Length - 2); - } - } - else if (typeof(IList).IsAssignableFrom(type)) - { - type_ = GetListItemType(type); - if (type_ == null) - { - type_ = ""; - isadd = false; - } - else { - isArray = true; - } - - } - int index = type_.IndexOf('+'); - - if (type_.IndexOf('+') > -1) - { - - type_ = type_.Replace('+', '.'); - } - - if (type_.IndexOf("`") > -1) - { - type_ = type_.Substring(0, type_.IndexOf("`")); - - } - - type_ = "CS." + type_; - } - - - foreach (LuaIdeInfo linfo in luaInfos) - { - if (linfo.tableName != null) { - - if (linfo.tableName == type_) - { - isadd = true; - } - } - - - } - - if (isArray) { - type_ = type_ + "<>"; - } - if (type_.IndexOf('[') > -1) - { - type_ = type_.Replace("[", "{"); - } - if (type_.IndexOf(']') > -1) - { - type_ = type_.Replace("]", "}"); - } - - return type_; - } - } - diff --git a/Assets/XLua/Src/Editor/LuaIde/LuaIdeInfo.cs.meta b/Assets/XLua/Src/Editor/LuaIde/LuaIdeInfo.cs.meta deleted file mode 100644 index 66b0f1c..0000000 --- a/Assets/XLua/Src/Editor/LuaIde/LuaIdeInfo.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 93117eecfdca060489ee604c58760f54 -timeCreated: 1503846117 -licenseType: Free -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/XLua/Src/Editor/LuaIde/luaIdeConfig.txt b/Assets/XLua/Src/Editor/LuaIde/luaIdeConfig.txt deleted file mode 100644 index b479da0..0000000 --- a/Assets/XLua/Src/Editor/LuaIde/luaIdeConfig.txt +++ /dev/null @@ -1,2 +0,0 @@ -锘�#瀵煎嚭璺緞 鐩稿浜巃ssets -./ResourcesOut/Lua diff --git a/Assets/XLua/Src/Editor/LuaIde/luaIdeConfig.txt.meta b/Assets/XLua/Src/Editor/LuaIde/luaIdeConfig.txt.meta deleted file mode 100644 index 1f6a622..0000000 --- a/Assets/XLua/Src/Editor/LuaIde/luaIdeConfig.txt.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: d9763e11571abd24283f54a18b7c526a -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: -- Gitblit v1.8.0