Skip to content

Debug ​

class in OpalScript

Write source-linked messages and assertions to the Console and browser developer tools.

Messages capture their values, script location and object when the call runs. LogError and failed Assert report an error without throwing. The editor's Pause on error option pauses at a safe execution boundary; exported games keep running. Logging is available in gameplay callbacks, including LocalInput, but not pure or computed functions.

Methods ​

MemberDescription
Debug.LogWrite a message or a detached snapshot of any value to the Console. Includes the calling script, source line, and object; exported games write to the browser console.
Debug.LogWarningWrite a warning to the Console with the calling script, source line, and object. Accepts any value and does not stop gameplay.
Debug.LogErrorWrite an error to the Console with the calling script, source line, and object. Accepts any value and does not throw. The editor can pause subsequent execution when Error Pause is enabled.
Debug.AssertWhen condition is false, log an assertion error with the supplied message or value. A true condition logs nothing. Assertions do not throw; the editor can pause subsequent execution when Error Pause is enabled.

Example ​

csharp
class DebugExample : Component {
    void Start() {
        Debug.Log("Player ready");
        Debug.Log(Transform.Position);
        Debug.LogWarning("Using the default spawn point");
        Debug.Assert(GetComponent<Health>() != null, "Add a Health component");
    }
}

See also ​