EditorHint function

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 9BitStrider
        if(Engine.EditorHint) {
            debug = true;
            GD.Print("Debug Mode Active!");
        } else {
            GD.Print("Editor not detected. Starting without debug.");
        }

Using the above to allow me to use debug mode when launching the game through Godot or VSC. However, the flag doesn’t seem to work. The above is in the game’s ready function at startup.

:bust_in_silhouette: Reply From: juppi

Look at the documentation of Engine.EditorHint. It says:

… To detect whether the script is run from an editor build (e.g. when
pressing F5), use Godot.OS.HasFeature(System.String) with the “editor”
argument instead. …

So this should work:

    if (OS.HasFeature("editor"))
    {
        GD.Print("Debug");
    }
    else
    {
        GD.Print("No Debug");
    }