使用Unity3D和编辑器脚本尝试在OSX终端中运行脚本。当从终端运行test.sh时,GDCL应用程序会执行其任务,然后输出参数。但是,如果我从Unity3D编辑器运行脚本,则只能在输出中获取参数。 GDCL不运行。
如何让Unity3D运行终端脚本?
C#脚本运行test.sh(仅提供输出)。
ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = Application.dataPath+"/test.sh";
psi.UseShellExecute = false;
psi.RedirectStandardOutput = true;
psi.Arguments = "arg1 arg2 arg3";
//psi.Arguments = "test";
Process p = Process.Start(psi);
string strOutput = p.StandardOutput.ReadToEnd();
p.WaitForExit();
UnityEngine.Debug.Log(strOutput);
test.sh脚本已经调整为chmod 777 (GDCL仅在终端中工作)
#!/bin/sh
GDCL ~/Documents/Unity/testproject/Assets/Font\ Normal.GlyphProject ~/Documents/Unity/testproject/Assets/Textures/fontNormal/font -fo PlainText-txt
for arg in $*
do
echo $arg
done