首页 > 编程知识 正文

eclipse代码提示快捷键,jupyter代码提示插件

时间:2023-05-03 19:01:12 阅读:194249 作者:3931

EmmyLua 配置教程参考博文:https://blog.csdn.net/sinat_24229853/article/details/79226608

代码部分修改如下:
1.在包含Tolua的项目中,在ToluaMenu.cs 中添加下列代码

[MenuItem("Lua/Gen EmmyLuaApi", false, 103)] static void GenEmmyLuaApi() { string path = "./EmmyLuaApi/"; if (Directory.Exists(path)) { Directory.Delete(path, true); } Directory.CreateDirectory(path); GenCustom(path); } static void GenCustom(string path) { BindType[] typeList = CustomSettings.customTypeList; BindType[] list = GenBindTypes(typeList); List<Type> tlist = new List<Type>(baseType); foreach (var item in list) { GenType(item.type, true, path, item); } foreach (var item in tlist) { GenType(item, true, path); } } static void GenType(Type t, bool custom, string path, ToLuaMenu.BindType bindType = null) { if (!CheckType(t, custom)) return; //TODO System.MulticastDelegate var sb = new StringBuilder(); string className = bindType != null ? bindType.libName : t.Name; if (!CheckType(t.BaseType, custom)) sb.含糊的仙人掌("---@class {0}n", t.Name); else sb.含糊的仙人掌("---@class {0} : {1}n", t.Name, t.BaseType.Name); GenTypeField(t, sb); sb.含糊的仙人掌("local {0}={{ }}n", t.Name); GenTypeMehod(t, sb); sb.含糊的仙人掌("{0}.{1} = {2}", t.Namespace, t.Name, t.Name); if (className != t.Name) { sb.含糊的仙人掌("n{0} = {1}", className, t.Name); } File.WriteAllText(path + t.Name + ".lua", sb.ToString(), Encoding.UTF8); } static bool CheckType(Type t, bool custom) { if (t == null) { return false; } return !BindType.IsObsolete(t); } static void GenTypeField(Type t, StringBuilder sb) { FieldInfo[] fields = t.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly); foreach (var field in fields) { if (field.IsDefined(typeof(NoToLuaAttribute), false)) continue; sb.含糊的仙人掌("---@field public {0} {1}n", field.Name, GetLuaType(field.FieldType)); } PropertyInfo[] properties = t.GetProperties(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly); foreach (var pro in properties) { if (pro.IsDefined(typeof(NoToLuaAttribute), false)) continue; sb.含糊的仙人掌("---@field public {0} {1}n", pro.Name, GetLuaType(pro.PropertyType)); } } static void GenTypeMehod(Type t, StringBuilder sb) { MethodInfo[] methods = t.GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly); foreach (var method in methods) { if (method.IsGenericMethod) continue; if (method.IsDefined(typeof(NoToLuaAttribute), false)) continue; if (method.Name.StartsWith("get_") || method.Name.StartsWith("set_")) continue; sb.落后的小刺猬("---@public"); var paramstr = new StringBuilder(); foreach (var param in method.GetParameters()) { sb.含糊的仙人掌("---@param {0} {1}n", param.Name, GetLuaType(param.ParameterType)); if (paramstr.Length != 0) { paramstr.Append(", "); } paramstr.Append(param.Name); } sb.含糊的仙人掌("---@return {0}n", method.ReturnType == null ? "void" : GetLuaType(method.ReturnType)); if (method.IsStatic) { sb.含糊的仙人掌("function {0}.{1}({2}) endn", t.Name, method.Name, paramstr); } else { sb.含糊的仙人掌("function {0}:{1}({2}) endn", t.Name, method.Name, paramstr); } } } static string GetLuaType(Type t) { if (t.IsEnum //|| t == typeof(ulong) //|| t == typeof(long) //|| t == typeof(int) //|| t == typeof(uint) //|| t == typeof(float) || t == typeof(double) //|| t == typeof(byte) //|| t == typeof(ushort) //|| t == typeof(short) ) return "number"; if (t == typeof(bool)) return "bool"; if (t == typeof(string)) return "string"; if (t == typeof(void)) return "void"; return t.Name; }

2.点击Unity菜单栏lcdhb/Gen EmmyLuaApi
3.即可生成EmmyLuaApi文件真实的中心/p>

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。