#やりたいこと
Processクラス, MSBuildを用いてUnity経由で.slnをビルドした時の標準出力を受け取り、
Debug.Log()でUnity上のコンソールに出力したい。
#症状
Unity上のコンソールで日本語の部分が文字化けして表示される。
#環境
Win10, Unity2017.4.2f2
#コード
C#:MSBuildCaller.cs
1using UnityEngine; 2using System.Diagnostics; 3using System.Text; 4 5public class MSBuildCaller : MonoBehaviour 6{ 7 [SerializeField] string MSBuildPath,ProjectPath; 8 //パスは伏せます。ビルド自体は問題なくできています。 9 public void Build() 10 { 11 Process process = new Process(); 12 process.StartInfo.FileName = MSBuildPath; 13 process.StartInfo.Arguments = ProjectPath + " /p:Configuration=Release /p:Platform=x86"; 14 process.StartInfo.UseShellExecute = false; 15 process.StartInfo.RedirectStandardOutput = true; 16 process.StartInfo.StandardOutputEncoding = Encoding.UTF8; 17 process.Start(); 18 string data = process.StandardOutput.ReadToEnd(); 19 UnityEngine.Debug.Log(data); 20 process.WaitFoeExit(); 21 } 22}
#試したこと
この記事を参考に出力をBOM付UTF8に変換するなどしてみましたが、症状は変わりませんでした。
あなたの回答
tips
プレビュー