Introduction
In this blog, we will learn about Unity Console, we also learn about Debug Class and its different functions. Unity, being a cross-platform engine, focuses on both 2D and 3D games development and interactive content. There is a complete toolkit for designing, interfaces ensuring that there is minimal use of external programs to get a job done on Unity.
Unity Console
To see the output of code, we use the console. These outputs will quickly test the lines of code without even adding functionality for testing. You can find the console region above the Assets region, in the labeled tab.
Outputs generated in the console are more useful for the programmer than the end-user or player.
To open the console from the main menu of the Unity Editor, you need to select the ‘Window’ tab from Tab Menu. A dropdown menu appears.
From the dropdown menu, select General, and another menu appears. From that menu, we will select Console.
For shortcut key users, press ‘Ctrl+Shift+C’.
There are many functions of the Debug Class that can be used to generate messages in the Console Window. The prominent three types of messages that appear in the default console, and are related to most of the compiler standards are-
- Errors
- Warnings
- Messages
Errors
Issues or Exceptions that don’t even allow the code to run, are Errors. In this case, the code won’t even proceed if errors are not resolved. Firstly, the programmer is required to resolve the errors, then only the code is expected to generate an output or even run.
Warnings
Such issues that won’t stop code from running, but will pose issues during Runtime, are Warnings. These warnings are needed to be taken care of so that it does not hamper the functionality of the code.
Messages
Messages do not usually highlight issues, they convey something to the user. Messages are much more useful when compared to Errors and Warnings as these not only convey something but also come up with the solution as to what can be done further.
Even when there is console output for Errors, Warnings, and Messages, we still use the Debug class.