Pause Level

v4.0

Pause Level

Gametime has a value for pauseLevel, an int value which specifies different tiers of pausing in the game. Generally a value of 0 means the game is not paused, and a value higher would imply there is some amount of pause.

While some games may just have two states, other projects will have multiple states, such as a level where enemies and projectiles stop moving, but the player can continue to work with the UI, while a higher pause level may keep the player from working with the UI, and only allow operation of the game settings menu.

Variables

// The active pauseLevel
public int pauseLevel = 0;

// This value is set by the script, and records the most recent pauseLevel
[SerializeField] private int lastPauseLevel = 0;

// If not -1, when this script is awakened, game will pause to this level
public int pauseLevelOnAwake = -1;

// If not -1, game will pause to this level when we change scenes.
public int pauseLevelWhenSceneChanges = -1; 

// If not -1, game will pause to this level when a new scene is loaded.
public int pauseLevelWhenNewSceneLoaded = -1; 

// Gametime will not advance if pauseLevel >= this value.
public int stopTimeOnPauseLevel = 1;

Methods

Examples

This example comes from DialoguePanel.cs in the Party Base RPG demo game. When the panel is enabled, the game should set to a pauseLevel that is set on the script itself.

Last updated

Was this helpful?