Unity Debugging - nomrand/__basics GitHub Wiki
Logging
normal logging.
Debug.Log("LOG!");
Debug.LogFormat("LOG! (normal){0}", 1 + 1); // LOG! (normal)2
Debug.Log($"LOG! (zero padding3){1 + 1:000}"); // LOG! (zero padding3)002
// WARNING
Debug.LogWarning("WAR!");
string aaa = "a";
Debug.LogWarningFormat("WAR! (space padding5){0, 5}x", aaa); // WAR! (space padding5) ax
Debug.LogWarning($"WAR! (space padding5){aaa, -5}x"); // WAR! (space padding5)a x
// ERROR
Debug.LogError("ERR!");
Debug.LogError(string.Format("ERR! (bracket){{{0}}}", 0.25)); // ERR! (bracket){0.25}
Debug.LogError($"ERR! (bracket){{{0.25}}}");
object specific (click the log message in console, specific object marked)
// Object specific
Debug.Log("message for this object", this);
Debug.Log("message for other object", other);
log file
C:\Users\[UserName]\AppData\Local\Unity\Editor\Editor.log
Gizmo
draw original gizmo
set Script which has [OnDrawGizmosSelected] method (like below), and then select the Object.
private void OnDrawGizmosSelected()
{
Vector3 fromPoint = Object1.transform.position;
Vector3 toPoint = Object2.transform.position;
// Draw Line
Gizmos.color = Color.yellow; // color select
Gizmos.DrawLine(fromPoint, toPoint);
// Draw Wire Sphere
float radius = 3.0f;
Gizmos.color = Color.green; // color select
Gizmos.DrawWireSphere(fromPoint, radius);
// Draw Sphere
Gizmos.color = Color.red; // color select
Gizmos.DrawSphere((fromPoint+toPoint)/2, 0.5f);
}