Console Logging

Printing messages to Console Log.

Scripts can print messages to the Modularity Console using:

ctx.AddConsoleMessage("[SampleInspector] Target not found", ConsoleMessageType::Warning);

Message Types

ctx.AddConsoleMessage("[Script] Saved settings", ConsoleMessageType::Success);
ctx.AddConsoleMessage("[Script] Something happened", ConsoleMessageType::Info);
ctx.AddConsoleMessage("[Script] This might be wrong", ConsoleMessageType::Warning);
ctx.AddConsoleMessage("[Script] Failed to load asset", ConsoleMessageType::Error);

Log once (avoid spam)

Useful when a button is pressed repeatedly or an IEnum loops:

static bool warned = false;

if (!warned)
{
    ctx.AddConsoleMessage("[SampleInspector] Target not found", ConsoleMessageType::Warning);
    warned = true;
}

Example: “Nudge Target” with logging


Common mistakes

  1. Starting the same IEnum every frame (start once, or use a handle / ensure-running).

  2. Logging inside a loop every tick (use log-once or a cooldown).

  3. Editing the scene while iterating scene lists (defer work to next tick if needed).

Last updated

Was this helpful?