UGameInstanceSubsystem
#include "Subsystems/GameInstanceSubsystem.h"
Access: public
Specifiers: UCLASSAbstract
Description
Subsystem base class whose lifetime matches the `UGameInstance`. Use for game-wide state that persists across level transitions, such as online session management, save-data caches, or cross-level event buses. Retrieved via `UGameInstance::GetSubsystem<T>()`.
Signature
UCLASS(Abstract, Within=GameInstance) class UGameInstanceSubsystem : public USubsystem Caveats & Gotchas
- • Alive from the moment the GameInstance is created until it is destroyed; survives seamless and non-seamless level loads.
- • Avoid storing raw `UWorld*` pointers — the world pointer changes on level transitions; use `GetWorld()` from a valid context instead.
Examples
Access from any actor C++
if (UGameInstance* GI = GetGameInstance())
{
if (UMySessionSubsystem* Sub = GI->GetSubsystem<UMySessionSubsystem>())
{
Sub->FindSessions();
}
} Null-safe static helper C++
UMySessionSubsystem* Sub = UGameInstance::GetSubsystem<UMySessionSubsystem>(GetGameInstance()); Version History
Introduced in: 4.22
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
| 5.0 | stable | — |
Feedback
Was this helpful?