CVars are global variables used for configuring the runtime. They are used for development to enable or modify hidden features.

Types of CVars

Only a strictly limited set of CVar types is supported:

Accessing and Modifying CVars

CVars are exposed in multiple ways.


In ezEditor you can open Panels > CVars to show a panel that allows you to modify CVars. Be aware that some CVars only have an effect when simulating the scene, and some even only when using Play-the-Game mode. The latter mostly happens when the effect of a CVar is implemented by a Game State.


ezInspector allows you to modify CVars of the connected process using the same UI as the editor.

In-Game Console

In-game a convenient way to modify CVars is the console.


CVars can also be accessed through the TypeScript API.

Command Line

CVars can be set through command line arguments using this syntax:

MyGame.exe -CvarName Value

For example:

MyGame.exe -Game.DebugDisplay true -fmod_MasterVolume 0.1

Values specified through the command line take precedence over stored values.

Saving State

The value of a CVar is typically discarded when the program closes, however, if the CVar uses ezCVarFlags::Save, it will be saved and restored in the next run. Be careful with this flag, as it can be very confusing when it is used to toggle subtle behavior. Be especially careful keeping this flag in for production code.

There is also ezCVarFlags::RequiresRestart which means that modifying that variable will take no effect unless you restart the application. This can be used for things like screen resolutions and other initial values.


You can subscribe to events for either all CVars or specific ones, to be informed when a CVar is modified.

Example Code

You create a CVar simply by instantiating it as a global variable somewhere in a cpp file:

#include <Foundation/Configuration/CVar.h>

ezCVarBool cvar_DebugDisplay("Game.DebugDisplay", false, ezCVarFlags::Default, "Whether the game should display debug geometry.");

Then you can just treat it like a regular variable to read or write its value:

if (cvar_DebugDisplay)
  ezDebugRenderer::DrawLineSphere(m_pMainWorld, ezBoundingSphere(ezVec3::ZeroVector(), 1.0f), ezColor::Orange);

See Also