diff --git a/Assets/Slua/Editor/ICustomExportPost.cs b/Assets/Slua/Editor/ICustomExportPost.cs new file mode 100644 index 00000000..4108154f --- /dev/null +++ b/Assets/Slua/Editor/ICustomExportPost.cs @@ -0,0 +1,8 @@ +using UnityEngine; +using System.Collections; + +namespace SLua{ + public interface ICustomExportPost { + + } +} \ No newline at end of file diff --git a/Assets/Slua/Editor/ICustomExportPost.cs.meta b/Assets/Slua/Editor/ICustomExportPost.cs.meta new file mode 100644 index 00000000..618be3d3 --- /dev/null +++ b/Assets/Slua/Editor/ICustomExportPost.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0517ba8e84e8c48869fc381b0fe501a3 +timeCreated: 1445479148 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Slua/Editor/LuaCodeGen.cs b/Assets/Slua/Editor/LuaCodeGen.cs index 6810d620..26763e2a 100644 --- a/Assets/Slua/Editor/LuaCodeGen.cs +++ b/Assets/Slua/Editor/LuaCodeGen.cs @@ -273,6 +273,19 @@ static public void Custom() } CustomExport.OnAddCustomClass(fun); + + //detect interface ICustomExportPost,and call OnAddCustomClass + assembly = System.Reflection.Assembly.Load("Assembly-CSharp-Editor"); + types = assembly.GetExportedTypes(); + foreach (Type t in types) + { + if(typeof(ICustomExportPost).IsAssignableFrom(t)){ + System.Reflection.MethodInfo method = t.GetMethod("OnAddCustomClass",System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public); + if(method != null){ + method.Invoke(null,new object[]{fun}); + } + } + } GenerateBind(exports, "BindCustom", 3, path); if(autoRefresh) @@ -1472,7 +1485,7 @@ bool isUsefullMethod(MethodInfo method) if (method.Name != "GetType" && method.Name != "GetHashCode" && method.Name != "Equals" && method.Name != "ToString" && method.Name != "Clone" && method.Name != "GetEnumerator" && method.Name != "CopyTo" && - method.Name != "op_Implicit" && + method.Name != "op_Implicit" && method.Name != "op_Explicit" && !method.Name.StartsWith("get_", StringComparison.Ordinal) && !method.Name.StartsWith("set_", StringComparison.Ordinal) && !method.Name.StartsWith("add_", StringComparison.Ordinal) && @@ -1729,12 +1742,15 @@ void Write(StreamWriter file, string fmt, params object[] args) file.Write("\t"); - if (args.Length == 0) - file.WriteLine(fmt); + if (args.Length == 0){ + file.Write(fmt); + file.Write("\r\n"); //TODO add by zilch,try to make win&mac generate same files. + } else { string line = string.Format(fmt, args); - file.WriteLine(line); + file.Write(line); + file.Write("\r\n"); } if (fmt.EndsWith("{")) indent++;