Skip to content

GameEvents class ​

Namespace Lustral · Assembly Lustral.Api

Scene and frame events for a mod. Handlers run on the game's main thread. An exception thrown by a handler is logged under the mod's ID and does not affect other handlers or other mods.

csharp
public sealed class GameEvents

Events ​

FixedUpdate ​

csharp
public event Action? FixedUpdate;

Raised once per physics step, together with the game's FixedUpdate methods and before the physics simulation. Physics steps occur at a fixed rate (50 per second by default) independent of the frame rate, so the event can be raised zero or more times per frame. Use it for forces and other physics work.

LateUpdate ​

csharp
public event Action? LateUpdate;

Raised once per frame, after the game's LateUpdate methods and therefore after all Update methods. Use it for cameras and other logic that depends on movement during the frame.

OnGUI ​

csharp
public event Action? OnGUI;

Raised for Unity's immediate mode GUI (GUI, GUILayout), drawn over the game, as a MonoBehaviour's OnGUI method is: several times per frame, once per GUI event (Event.current: layout, repaint, input). Lustral enables Unity's GUI only after a mod subscribes, because it has a per-frame cost. Some game builds exclude Unity's IMGUI module; Lustral then logs a message and the event is not raised. On IL2CPP games, GUI methods that the game does not use may be stripped from the build, and those that Lustral cannot restore are absent from the interop assemblies.

SceneLoaded ​

csharp
public event Action<SceneInfo>? SceneLoaded;

Raised after a scene has loaded. For the first scene, it is raised after Mod.OnGameReady.

SceneUnloaded ​

csharp
public event Action<SceneInfo>? SceneUnloaded;

Raised after a scene has been unloaded.

Update ​

csharp
public event Action? Update;

Raised once per frame, after the game's Update methods. Mods that do not subscribe incur no per-frame cost.

Mods are third-party software. Lustral does not verify their behavior and is not responsible for any damage they cause.