??
Sun Guangdong: 2015-2-7/1:19 reprint Please specify the Source: http://blog.csdn.net/u010019717
More full content Please see my game Bull address: http://www.unitymanual.com/space-uid-18602.html
Let's take a look at the effect: Say goodbye to boredom and monotony!
In fact, the simple thing is to have rich text tags in the string, because unity supports it, so it's OK.
You can read the following details:
Http://docs.unity3d.com/Manual/StyledText.html
Then we individually test the editor and the game separately.
Add the following code:
Create a new "Editor" folder and add the following two files.
EditorHelper.cs
Using unityengine;using system.collections;public static class editorhelper{//...} <summary>///Personalized Editor's LOG output format///</summary>public static class Editorlog{public static void Log (string Log) {Debug.Log (string. Format ("<b><color={0}><size={1}>{2}</size></color></b>", "lime", page, log));} public static void LogError (String LogError) {Debug.logerror (string. Format ("<b><color={0}><size={1}>{2}</size></color></b>", "Red", LogError) );} public static void Logwarning (String logwarning) {debug.logwarning (string. Format ("<b><color={0}><size={1}>{2}</size></color></b>", "Yellow", 15, logwarning));}}
MyEditor.cs
Using unityengine;using system.collections;using Unityeditor;public class Myeditor:editorwindow {[MenuItem ("Game/My Editorwindow #%&a ")] //shortcut key Shift + Ctrl + Alt +astatic void Init () {//Get existing open window or if none, make A new one:myeditor window = (myeditor) Editorwindow.getwindow (typeof (Myeditor));} Use the This for Initializationvoid onenable () {EditorLog.Log ("This is the test for editor's normal output! "); Editorlog.logwarning ("This is the test of editor warning output! "); Editorlog.logerror ("This is the editor error output test! ");}}
Then we'll see the console output in the editor by clicking on the menu below.
The script continues to be written. Do not put it under a special folder.
GameHelper.cs
Using unityengine;using system.collections;public static class gamehelper{//...} <summary>///Personalized Editor's LOG output format///</summary>public static class Gamelog{public static void log (string log ) {Debug.Log (string. Format ("<b><color={0}><size={1}>{2}</size></color></b>", "lime", page, log));} public static void LogError (String LogError) {Debug.logerror (string. Format ("<b><color={0}><size={1}>{2}</size></color></b>", "Red", LogError) );} public static void Logwarning (String logwarning) {debug.logwarning (string. Format ("<b><color={0}><size={1}>{2}</size></color></b>", "Yellow", 15, logwarning));}}
GameLogTest.cs
Using unityengine;using System.Collections; [Executeineditmode]public class Gamelogtest:monobehaviour {//Use this for initializationvoid Start () {GameLog.Log ("it is Test the normal output of the game! "); Gamelog.logwarning ("This is the test of the game warning output! "); Gamelog.logerror ("This is the test of the game error output! ");} Update is called once per framevoid update () {}}
We hang the script GameLogTest.cs on any object in the scene. You will see the new output from the console.
Ok
Unity3d Console Private Customization