ログ付きのUnityエクスポートEXE



Unity Export Exe With Log



using UnityEngine using System.Collections using System.IO public class GuiDebug : MonoBehaviour { private bool bShow = false public Rect windowRect0 = new Rect(80, 100, 420, 366) public string mSzLog = '' // Use this for initialization void Start() { } void OnEnable() { Application.RegisterLogCallback(HandleLog) } void OnDisable() { Application.RegisterLogCallback(null) } StreamWriter writer void HandleLog(string logString, string stackTrace, LogType type) { //output = logString //stack = stackTrace mSzLog += logString + ' ' WriteIntoTxt(mSzLog) } / / Write all the data into the text public void WriteIntoTxt(string message) { FileInfo file = new FileInfo(Application.dataPath + '/StreamingAssets/mytxt.txt') if (!file.Exists) { writer = file.CreateText() } else { writer = file.AppendText() } writer.WriteLine(message) writer.Flush() writer.Dispose() writer.Close() } // Update is called once per frame void Update() { //if (Input.GetKeyUp(KeyCode.P)) //{ // bShow = !bShow // if (bShow) // { // OnEnable() // } // else // { // OnDisable() // } //} } void DoMyWindow(int windowID) { if (GUI.Button(new Rect(20, 20, 80, 20), 'Add')) { mSzLog += 'Hello!! ' } if (GUI.Button(new Rect(120, 20, 80, 20), 'Clear')) { mSzLog = '' } GUI.TextArea(new Rect(20, 50, 380, 300), mSzLog) //GUI.DragWindow()// GUI.DragWindow(new Rect(0, 0, 600, 480)) // } void OnGUI() { if (bShow) { windowRect0 = GUI.Window(0, windowRect0, DoMyWindow, 'Draggable Window') } } }

テキストは手動で作成する必要があります。