提交 8f61437a 编写于 作者: J johnche(车雄生)

支持通过拷贝unity2017的MonoBleedingEdge来解决unity2018生成代码里,mscorlib的api会多一些的问题。

上级 227cd58c
......@@ -1615,6 +1615,13 @@ namespace CSObjectWrapEditor
[MenuItem("XLua/Generate Code", false, 1)]
public static void GenAll()
{
#if UNITY_2018 && UNITY_EDITOR_WIN
if (File.Exists("./Tools/MonoBleedingEdge/bin/mono.exe"))
{
GenUsingCLI();
return;
}
#endif
var start = DateTime.Now;
Directory.CreateDirectory(GeneratorConfig.common_path);
GetGenConfig(XLua.Utils.GetAllTypes());
......@@ -1632,6 +1639,63 @@ namespace CSObjectWrapEditor
AssetDatabase.Refresh();
}
#if UNITY_EDITOR_OSX || UNITY_EDITOR_WIN
public static void GenUsingCLI()
{
#if UNITY_EDITOR_OSX
var monoPath = "./Tools/MonoBleedingEdge/bin/mono";
#else
var monoPath = "./Tools/MonoBleedingEdge/bin/mono.exe";
#endif
var args = new List<string>()
{
"./Tools/XLuaGenerate.exe",
"./Library/ScriptAssemblies/Assembly-CSharp.dll",
"./Library/ScriptAssemblies/Assembly-CSharp-Editor.dll",
GeneratorConfig.common_path
};
var searchPaths = new List<string>();
foreach (var path in
(from asm in AppDomain.CurrentDomain.GetAssemblies() select asm.ManifestModule.FullyQualifiedName)
.Distinct())
{
try
{
searchPaths.Add(Path.GetDirectoryName(path));
}
catch { }
}
args.AddRange(searchPaths.Distinct());
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = monoPath;
process.StartInfo.Arguments = "\"" + string.Join("\" \"", args.ToArray()) + "\"";
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.Start();
while (!process.StandardError.EndOfStream)
{
Debug.LogError(process.StandardError.ReadLine());
}
while (!process.StandardOutput.EndOfStream)
{
Debug.Log(process.StandardOutput.ReadLine());
}
process.WaitForExit();
GetGenConfig(XLua.Utils.GetAllTypes());
callCustomGen();
AssetDatabase.Refresh();
}
#endif
[MenuItem("XLua/Clear Generated Code", false, 2)]
public static void ClearAll()
{
......
......@@ -22,14 +22,16 @@ namespace XLua
return;
}
if (args.Length > 1)
List<string> assemblyPathList = args.TakeWhile(path => path.EndsWith(".dll", StringComparison.OrdinalIgnoreCase)).ToList();
if (args.Length > assemblyPathList.Count)
{
GeneratorConfig.common_path = args[1];
GeneratorConfig.common_path = args[assemblyPathList.Count];
}
if (args.Length > 2)
if (args.Length > assemblyPathList.Count + 1)
{
List<string> search_paths = args.Skip(2).ToList();
List<string> search_paths = args.Skip(assemblyPathList.Count + 1).ToList();
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler((object sender, ResolveEventArgs rea) =>
{
foreach (var search_path in search_paths)
......@@ -44,7 +46,8 @@ namespace XLua
});
}
var assembly = Assembly.Load(File.ReadAllBytes(Path.GetFullPath(args[0])));
var allTypes = assemblyPathList.Select(path => Assembly.Load(File.ReadAllBytes(Path.GetFullPath(path))))
.SelectMany(assembly => assembly.GetTypes());
Generator.GenAll(new XLuaTemplates()
{
LuaClassWrap = new XLuaTemplate()
......@@ -92,7 +95,7 @@ namespace XLua
name = "TemplateCommon",
text = global::XLuaGenerate.Src.XLuaTemplates.TemplateCommon_lua,
},
}, assembly.GetTypes());
}, allTypes);
}
}
}
文件已添加
文件已添加
文件已添加
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册