- Home /
Show error when running in Application.
It's easy to show some "Error" or Debug information in debug mode when it will be print in Console window.
But is there any way to show these things when running Application ?Because I found when it run fine in Debug mode,it may still some error run in application, if it can show something wrong or Debug information, it will be help for finding the problem.
Although we may use "try{}catch{}" to do the Exception,But is there any good way to do that?
What OS are you using? I know how to do it on $$anonymous$$ac, but not on Windows.
Answer by Veehmot · Oct 18, 2011 at 01:54 AM
You can make your own console in-game. It also helps you to better debug. I share you my script:
using UnityEngine;
using System.Collections;
public class Console : MonoBehaviour {
float height = 150f;
static private string text = "Unity Console v1.4.567\n";
Vector2 scrollPosition = new Vector2(0,0);
void OnGUI() {
scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width (Screen.width), GUILayout.Height(height));
GUILayout.TextArea(text, GUILayout.MinHeight(height));
GUILayout.EndScrollView();
}
static public void Add(string line) {
text = text + line + "\n";
}
}
To use it, just attach this script to a GameObject and call Console.Add.
Update
A more elegant solution that doesn't require you to add a console to the game is to locate the error log files. They are described in this page: http://docs.unity3d.com/Documentation/Manual/LogFiles.html
Although, this doesn't provide you with any of Unity's builtin errors or exceptions (which are sometimes vital in tracking down a bug). For personal debug, though, it works.
Your answer
![](https://koobas.hobune.stream/wayback/20220613012757im_/https://answers.unity.com/themes/thub/images/avi.jpg)