in Editor/Scripts/ProtocCompiler.cs [54:102]
static bool CompileProto(string protoFilePath, string[] includePaths, 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(outputPath);
string args = string.Format("\"{0}\" --csharp_out \"{1}\" ", protoFilePath, outputPath);
foreach (string s in includePaths)
{
args += string.Format(" --proto_path \"{0}\" ", s);
}
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.LogErrorFormat("ProtocCompiler error:\n" + error);
}
AssetDatabase.Refresh();
return string.IsNullOrEmpty(error);
}