Unity编辑器调用外部exe程序
2021-06-11 19:02
标签:code generic win nbsp sys output gen card eric 直接来,1个脚本 参考资料: https://www.jianshu.com/p/3f4120a7c7f6 Unity编辑器调用外部exe程序 标签:code generic win nbsp sys output gen card eric 原文地址:https://www.cnblogs.com/sanyejun/p/14221085.htmlusing System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using UnityEditor;
using Debug = UnityEngine.Debug;
public class Excel2LuaEditor : EditorWindow
{
[MenuItem("工具/生成Lua Card")]
static void GenLuaCard()
{
Debug.Log("生成卡牌 Lua");
ProcessCommand(@"D:\UnitySSDProject\GameTRPG\GameTRPG\工具\Excel2Lua\Excel2Lua\Lua生成器\cardexe\bin\Excel2Lua.exe", null);
}
[MenuItem("工具/生成Lua Buff")]
static void GenLuaBuff()
{
Debug.Log("生成Buff Lua");
ProcessCommand(@"D:\UnitySSDProject\GameTRPG\GameTRPG\工具\Excel2Lua\Excel2Lua\Lua生成器\buffexe\bin\Excel2Lua.exe", null);
}
private static void ProcessCommand(string command, string argument){
ProcessStartInfo start = new ProcessStartInfo(command);
start.Arguments = argument;
start.CreateNoWindow = false;
start.ErrorDialog = true;
start.UseShellExecute = true;
if(start.UseShellExecute){
start.RedirectStandardOutput = false;
start.RedirectStandardError = false;
start.RedirectStandardInput = false;
} else{
start.RedirectStandardOutput = true;
start.RedirectStandardError = true;
start.RedirectStandardInput = true;
start.StandardOutputEncoding = System.Text.UTF8Encoding.UTF8;
start.StandardErrorEncoding = System.Text.UTF8Encoding.UTF8;
}
Process p = Process.Start(start);
if(!start.UseShellExecute){
Debug.Log(p.StandardOutput);
Debug.Log(p.StandardError);
}
p.WaitForExit();
p.Close();
}
}
上一篇:203. 移除链表元素(C++)
下一篇:Java序列初始化