Unity3d Console Private Customization

Source: Internet
Author: User

??

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.