Editor Console Pro on the Unity Asset Store

Asset Review – Editor Console Pro

We’re starting a new series! Once in a while The Knights of Unity will be reviewing assets from the Asset Store. In the first post we will take a closer look at Editor Console Pro.

editor console pro in the Unity Asset Store

Overview

Editor Console Pro is an Unity editor extension and a replacement for standard Unity console window. Its primary objective is to make the best of Unity logs. The hottest feature is probably the ability to display source code snippets instead of raw backtrace file names and line numbers.

editor console pro screenshot 1

The first thing you may want to do after seeing the backtrace is going to source files and seeing where and how the log has been produced (or exception occurred.) It’s such a common thing to do that after you realize that displaying code snippets instead of line numbers works much better, you’ll wonder why haven’t you used it before! What’s more, clicking on any visible code line will take you directly to that place!

Another great feature is log filtering. Big games typically have lots of logs. Sometimes they may be used to debug a specific behavior and sometimes there are log messages that (maybe) should be there, but are not necessarily visible to you every time. For these and any other cases you can set up a filter. You are able to submit a quick filter (the filtering text input is always visible,) or define custom filters to be displayed right next to standard filters (these are Log, Warn, Error and Exception).

editor console pro quick filter

If this is not enough, can save your filters to preferences file, so when you’ll be working on a single project with other people, you’ll be able to share your filters with them!

There is also a special kind of filters called simply Ignore. It can be found in preferences window.

editor console pro ignore

Logs filtered with the use of these conditions will not be displayed in the console window. This will help you to hide logs you don’t want to see.

ECP is highly customizable as well. You can choose your own font, font size, decide which columns should be visible. There are also other options that you will find in the preferences window.

The quality

Editor Console Pro asset is distributed as a DLL library. It’s a wise choice for editor extensions, because it works even when Unity fails to compile project scripts when started. The downside is that the source code is not available for the customer.

I never had any issues with Editor Console Pro except one. Prior to Unity 5 you could only set one log callback (for getting log messages from inside the engine). By trying to read the logs you were forced to remove any previously set callback. No need to mention that ECP was using this particular callback to get the logs for itself. This gave me a serious headache for a short period.

The documentation

This type of asset does not need a lot of documentation, but one short readme file is, to be honest, too little. It would be nice of the author if he could prepare an illustrated PDF or more web page content.

Summary

 

Asset Store URL: https://www.assetstore.unity3d.com/en/#!/content/11889?aid=1011lGBH

Pros

  • Great quality
  • Actively supported
  • Low price ($30)
  • Really makes a difference

Cons

  • No sources, only dll
  • Documentation could be better

Score: 8 / 10

Accessing Your Unity Game Logs

Unity allows you to log variety of messages into the Console window by using Debug.Log() function family. I don’t think that I need to convince anyone about how useful the logs are. However, did you know that when you’ve already built your application, you still are able to access your game logs?

Accessing logs from the editor

First things first. The Console window is not the only way to see the logs. Unity is constantly appending all the editor messages into a special text file.  This file can be accessed by clicking on the small “hamburger” icon in your Console window and then by selecting Open Editor Log option.

console open editor log

The screenshot above is from Unity 4. For Unity 5 there will be two log options instead:

  • Open Player Log
  • Open Editor Log

Player Log will contain only logs that are normally created by the Unity player. This includes user (game developer) logs. The Editor Log on the other hand, is the group of logs logged by the Unity editor itself and the editor scripts. You may want to take a look at these if you want to check why your build is so damn big.

Accessing standalone logs

What about the logs of an already built game? You might not know that, but the Unity player is logging the standalone messages to output_log.txt file inside the _Data folder of your game. Just go where your game executable is and enter the _Data directory (its name depends of the name of your game).data directory

Then inside you will find the output_log.txt file (there will be many other files too that you shouldn’t modify in any way).

b3677224-4cc5-4a9f-97b3-c9272cad540b

For the Mac standalone situation is a little more complicated. All Unity games logs can be found in a single place and this is ~/Library/Logs/Unity/Player.log file. It may be a little tricky to access because the Library folder is not visible in the Finder by default. To access it easily, click once on your desktop (or open Finder), then choose Go/Go To Folder from the main menu or use the ⇧⌘G shortcut.

mac go to folder

Then enter the folder location.

mac go to folder unity logs

And you’re there!

mac unity logs folder

Accessing iOS logs

The Unity iOS player works a little different than the standalone player. It does not log the messages to a file but you are still able to access it. All you need to do is to launch your game from XCode. After a while you will see log messages from your game.

xcode logs

Accessing Android logs

The Unity Android player works very similar to iOS player.

Logs are not stored in text files, still you can access them:
1. Connect your Android device to your PC using USB cable
2. Open monitor.bat or monitor.sh (depends on your operating system)*
* – Can be found in Android Developer Tools package in sdk/tools directory.

android device monitor

Android Device Monitor allows you to connect to your Android device and display its logs (LogCat window). Be aware that LogCat by default will produce logs from all the applications running on your device (even those that are running in the background) and operating system itself. Therefore, you may find it difficult to separate your game logs from the rest. To help you with that, you may create the LogCat filters. The Unity player messages are logged with Unity tag, so it will be quite easy to create an adequate filter.

More information

You can find a page in Unity manual that contains paths and quick instructions on how to access logs on different platforms. If you consider this information useful, add it to your bookmarks for the future use.

Use Debug.Break() to pause Unity editor from the code

You can pause your game from the editor any time you want. But did you know that you can trigger the pause from the code based on some condition?

error pause console

There’s a console option called Error Pause. When enabled, it will pause your game when any run-time error occurs. When your game is paused, you can easily investigate what is going on your scene so you can better understand the problem. But what if you want to pause your game on a custom condition? It can also be done!

In order to do this, you have to use the Debug.Break() function. Just call it when you want to pause your Unity editor.

Example

This example displays a button in the top-left corner. When the button is clicked, the editor pauses.

Debug.Break() has one more significant advantage over manual pausing and stepping forward. It can pause your game in the middle of an execution frame. This means that part of your object may be still waiting for the Update() call and the other part has already been updated. This is really useful for situations when you’re dealing with a bug that appears randomly.

Don’t worry about leaving Debug.Break() functions in your code. When your game is built it literally does nothing! 🙂

Files

As usual, you can download the example unitypackage here. Just double-click on it to import its contents into your Unity project. You will find there an example scene and the script from above.

Console log can show you which object is the creator

Most probably you already know about Debug.Log() function and its variations, but did you know that you can use it to find a particular object on the scene?

Why would you do that? For instance, let’s say that you’re creating a shooting game. When a player shoots the object, you want to check if the bullet hits the right one. How can you do that?

Debug.Log() function can have one or two parameters:

debug log definition

The first one is a message. It can be a string or an object that will be converted to a string. The second one is a context. As a context you should pass the object that current message applies to. In our case, this would be the target hit of the bullet.

Example

Let’s take a look at this example:

In this example we wait for a mouse click (7), then do a ray-cast from the camera position (12), check if hit object is the current game object (15) and finally display the “Hit!” log message (18). By passing this as the second parameter, the log entry is aware of its creator and we are able to easily trace it back.

See that yellow highlighting animation around the object name in the Hierarchy? In that way the Unity tells you that this object is the creator.

You may ask: why not simply log object name like Debug.Log(name);? The answer is really simple. If you generate scene objects, most probably all of them are called the same. This is perfectly legal  (normal?) for Unity to have multiple hierarchy objects with the same name, so Debug.Log() with context parameter comes to the rescue!

Files

If you’d like to check it by yourself, you can download the unitypackage file, then double-click on it to import its content into your Unity project. You will find there an example scene and a script from above.