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
| Member | Description |
|---|---|
| Debug.Log | Write 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.LogWarning | Write a warning to the Console with the calling script, source line, and object. Accepts any value and does not stop gameplay. |
| Debug.LogError | Write 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.Assert | When 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");
}
}