Debugging - Unity
3 June 2020
There is a really neat way that you can turn on and off all your assistant testing code in a file. At the top of your file put the following code
#define DEBUG_FILEASSIST
and then put all you debugging and testing code within a similar set of hash tags thus,
#if DEBUG_FILEASSIST
private void OnDrawGizmos()
{
Debug.Log("Text: ");
if (Application.isPlaying)
{
Gizmos.color = Color.white;
Gizmos.DrawWireSphere(mousePoint3D, 0.2f);
Gizmos.DrawLine(transform.position, mousePoint3D);
}
}
#endif
now if you comment out the ##define DEBUG_FILEASSIST , then all code and comments between the #if DEBUG_FILEASSIST will automatically be commented out as well. You don't need to go through the whole file to find all your debugs and helper code. It will look like this
//#define DEBUG_FILEASSIST
#if DEBUG_FILEASSIST
private void OnDrawGizmos()
{
Debug.Log("Text: ");
if (Application.isPlaying)
{
Gizmos.color = Color.white;
Gizmos.DrawWireSphere(mousePoint3D, 0.2f);
Gizmos.DrawLine(transform.position, mousePoint3D);
}
}
#endif
Neat eh!