Unity3d console customization, unity3d Console

Source: Internet
Author: User

Unity3d console customization, unity3d Console

Sun Guangdong: 2015-2-7/1: 19 reprint please indicate the source: http://blog.csdn.net/u010019717

More comprehensive content please see my game pretty cool address: http://www.unitymanual.com/space-uid-18602.html

Let's take a look at the effect first: Say goodbye to boring and monotonous!

In fact, it is very simple to mark the string with Rich Text. It is enough to use it because unity supports it.

You can read the following details:

Http://docs.unity3d.com/Manual/StyledText.html

Then we will test it in the Editor and in the game respectively.

Add the following code:

Create the "Editor" folder and add the following two files.

EditorHelper. cs

Using UnityEngine; using System. collections; public static class EditorHelper {//......} /// <summary> // format the Log output of the personalized editor /// </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", 15, log);} public static void LogError (string logError) {Debug. logError (string. format ("<B> <color = {0}> <size = {1}> {2} </size> </color> </B> ", "red", 15, 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 this for initializationvoid OnEnable () {EditorLog. log ("this is the normal output test of the Editor! "); EditorLog. LogWarning (" this is a test of Editor warning output! "); EditorLog. LogError (" this is a test of Editor error output! ");}}

Click the following menu in the editor to view the console output.



Continue to write the script. It is not placed under a special folder.

GameHelper. cs

Using UnityEngine; using System. collections; public static class GameHelper {//......} /// <summary> /// format the Log output of the personalized editor /// </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", 15, log);} public static void LogError (string logError) {Debug. logError (string. format ("<B> <color = {0}> <size = {1}> {2} </size> </color> </B> ", "red", 15, 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 ("this is a test of normal Game output! "); GameLog. LogWarning (" this is a test of the Game warning output! "); GameLog. LogError (" this is a test of Game error output! ") ;}// Update is called once per framevoid Update (){}}


Run the scriptGameLogTest. cs is mounted to any object in the scenario. The new output is displayed.

OK



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.