Debug.Log("Hello, World");
// Debug.Log can be used to print text to the console.
Debug.Log("It worked!");
// Debug.Log can print the value of a float/bool/int/etc... to the console.
float number = 10f;
Debug.Log(number);
using UnityEngine;
using System.Collections;
public class MyGameClass : MonoBehaviour
{
void Start()
{
Debug.Log("Logging Message to Console");
Debug.LogWarning("Logging Warning to Console");
Debug.LogError("Logging Error to Console");
}
}
In Unity C#, Debug.Log() and print() are functionally identical
print() is just a bit easier to remember than Debug.Log()
print() is inherited from the MonoBehavior class, so any project without
public class ExampleClass : MonoBehavior {}
will not be able to use print()
#if UNITY_EDITOR
Debug.logger.logEnabled = true;
#else
Debug.logger.logEnabled = false;
#endif