Unity Debug Log Text display updated clearly

Source: Internet
Author: User

Debugging is one of the most basic skills of our programmers, when we become impetuous or some limit ourselves. We start by giving up debugging mechanisms to get results in a short time.

A small story: just into the game industry I came to a medium-sized game development company, when the heart is very excited to learn a lot of things here, such as teamwork, frame construction and so on. =. = Almost all the old programmers left the job in the 2nd week, and the last programmer stayed for no more than 5 months. At that time frightened me to cry, causes the programmer to leave the collective to have many reasons, some wages open less, some projects dragged too long.  I heard that our project has been developing for nearly 3 years. I was assigned to do iOS pack and Go SDK, and I found out that the project actually had such a thing. is the unity Mac Click Run is not running, must be contracted to the mobile phone to be able to. The director of the project explained to me that I could only run on my mobile phone, and I haven't helped you out on Mac computers . This sentence caused me and the city half an hour to solve the problem, for 1 weeks and still reluctantly fixed some bugs. =.= I can only secretly laugh, you do so how to debug the program? And we actually went to fix the bug, even the game can not run on the Mac this bug is actually behind the fix. Well, the director's not okay.

Back to our question, I would like to tell you how to add some tips to Debug.Log () to quickly locate errors and to let people unfamiliar with the project know that the person is responsible for something wrong.

We often use Debug.log () to display some information on the console to help us see the error

Liezi:

Debug.Log (" resource loaded ");D ebug. Log (" Show Purchase window page ");D ebug. Log (" I'm running ");            // This invalid log generally I like to do so oh, eat excrement

In some ways these words are not wrong, but suppose a finds that the game is not running, and that the "Resource loading error" of this vague text. If a is not a development resource loaded he is unable to locate the specific location.

After the optimized log the first way:

Debug.Log (" Resource Module-load resource error "  );D ebug. Log (" Resource Module-lead map not found " );

The second way: (Of course I do not know whether Xcode and Eclipselog can directly see the specific is that class, function reported errors, generally this we are displayed in the GUI Debugging center )

Debug.Log (" class name-function name-log content ");

Third Way:

Debug.Log ("module name- class name-function name-log content ");

Second, how to capture the text of Debug.Log ()

A callback function is provided in the application class whenever the Debug.Log is triggered

Registration callback function: application.registerlogcallback (logcallback);

 Public voidLogcallback (stringConditionstringstackTrace, LogType type) {        Switch(type) { CaseLogType.Log://Normal Log                 Break;  Caselogtype.exception://the report is abnormal.                 Break;  CaseLogtype.error://error Message                 Break;  Caselogtype.warning://Warning Information                 Break; default:                 Break; }    }

Unity Debug Log Text display updated clearly

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.