Debug.Log를 화면에 보여주기 (GUILayout)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MyLog : MonoBehaviour
{
string myLog;
Queue myLogQueue = new Queue();
private GUIStyle guiStyle = new GUIStyle();
void Start()
{
guiStyle.fontSize = 20;
Debug.Log("MyLog Start");
}
void OnEnable()
{
Application.logMessageReceived += HandleLog;
}
void OnDisable()
{
Application.logMessageReceived -= HandleLog;
}
void HandleLog(string logString, string stackTrace, LogType type)
{
myLog = logString;
string newString = "\n [" + type + "] : " + myLog;
myLogQueue.Enqueue(newString);
if (type == LogType.Exception)
{
newString = "\n" + stackTrace;
myLogQueue.Enqueue(newString);
}
myLog = string.Empty;
foreach (string mylog in myLogQueue)
{
myLog += mylog;
}
}
void OnGUI()
{
GUILayout.Label(myLog, guiStyle);
}
}
'Unity > Input' 카테고리의 다른 글
[Unity] 버튼에 마우스 클릭 이벤트 사용하기 (0) | 2020.09.21 |
---|---|
[Unity] 마우스 클릭 지점으로 이동 (0) | 2020.09.16 |
[Unity] 캐릭터 좌우로 움직이기 (RigidBody) (0) | 2020.09.12 |