in Editor/Scripts/ProtocCompiler.cs [104:148]
static bool CreateDescriptor(string protoFilePath, string outputPath)
{
if (Path.GetExtension(protoFilePath) != ".proto") return false;
if (!File.Exists(binaryPath))
{
UnityEngine.Debug.LogErrorFormat("Protoc binary file does not exist: {0}", binaryPath);
return false;
}
if (!File.Exists(protoFilePath))
{
UnityEngine.Debug.LogErrorFormat("Proto file does not exist: {0}", protoFilePath);
return false;
}
Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
string args = string.Format(
"\"{0}\" -I\"{1}\" -o\"{2}\"", protoFilePath, Path.GetDirectoryName(protoFilePath), outputPath);
var startInfo = new ProcessStartInfo() {FileName = binaryPath, Arguments = args};
var proc = new Process() {StartInfo = startInfo};
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.RedirectStandardError = true;
proc.Start();
string output = proc.StandardOutput.ReadToEnd();
string error = proc.StandardError.ReadToEnd();
proc.WaitForExit();
if (!string.IsNullOrEmpty(output))
{
UnityEngine.Debug.Log("ProtocCompiler output:\n" + output);
}
if (!string.IsNullOrEmpty(error))
{
UnityEngine.Debug.LogError("ProtocCompiler error:\n" + error);
}
AssetDatabase.Refresh();
return string.IsNullOrEmpty(error);
}