In this Unity tutorial, I’m gonna teach you how to write Debug.Log statements that are both more meaningful and easier to read.
Download the project at https://www.patreon.com/posts/29898031
In this Unity tutorial, I’m gonna teach you how to write Debug.Log statements that are both more meaningful and easier to read.
Download the project at https://www.patreon.com/posts/29898031
Thanks for your useful channel!
For 4K I use a 42 inches curve TV as a monitor at about 73cm away. This give you room in the table for books, sketchbooks, etc…
I add a toggle for debugging
I add the name of my script into the debug.
And This is my template
using UnityEngine;
/**************************************************************************************
*
* Soaring Stars Lab
* 2020 Alan Mattano
* #SCRIPTNAME#
*
* .
*
* .
*
* ************************************************************************************/
public class #SCRIPTNAME# : MonoBehaviour
{
#region VARIABLES
public bool console = true;
[Space][Header("#SCRIPTNAME#")]
[Space(25)]
[Space]
// PUBLIC
[Range(0, 3.5f)]
[Tooltip("Info")]
public float value;
// PRIVATE
#endregion
void Awake()
{
if (console) Debug.Log("#SCRIPTNAME# Awake and writing...\n");
}
void Start ()
{
#NOTRIM#
}
void Update ()
{
#NOTRIM#
}
//------------------------------- FUNCTIONS ------------------------------------
} // --------------------------------------------------------------- Alan Mattano }}
From that, I delete a lot but faster than adding.
All my scripts have it’s console boolean for debugging.
After testing the script I just turn it off.
I take it out when profiling just before shipping using substitution.
Or when refactoring if the code is very simple.
My keyboard has a programmable button that types
if (console) Debug.Log("\n");
but just a copy and past from awake is better because it contains the script name.
TDD helps a lot to reduce console debugging: