UnrealSharp
  • Home
  • FAQ
  • Getting Started
    • Setup
    • Your First Script
    • Debugging
    • Packaging
  • Documentation
    • Classes
      • Properties
        • C++ Functions As C# Properties
        • C++ Properties with Getters/Setters
      • Functions
        • Flags
        • MetaData
      • Default Actor Components
      • Helper Methods
    • Structs
    • Enums
    • Interfaces
    • Delegates
    • Collections
      • TArray
      • TNativeArray
      • TSet
      • TMap
    • Multiplayer
      • Replicated Properties
      • RPCs (Remote Procedure Calls)
      • Replicated UObjects
    • Primary Data Assets
      • Loading Primary Data Assets
    • Loading Soft References
    • Trace Channels
    • Static Variables
      • FWorldStaticVar<T>
      • FGameStaticVar<T>
    • Logging
    • Async
    • Gameplay Tags
      • Gameplay Tag Container
    • Extension / Mixin Methods
    • Subsystems
    • Module Lifecycle
  • Links
    • Github Repository
    • Roadmap
    • Discord
Powered by GitBook
On this page
  1. Documentation
  2. Static Variables

FGameStaticVar<T>

FGameStaticVar<T> is a class designed to manage static variables that will persist during the whole game.

In editor the value will reset on Play In Editor start/end and on hot reload.

Declaration and Usage

You can declare a game-static variable like this:

public static readonly FGameStaticVar<float> MyStaticFloat = new();

To use it within your C# code:

public class AMyActor : AActor
{
    public static readonly FGameStaticVar<float> MyStaticFloat = new();
    
    public AMyActor()
    {
        // Set the value to 70 for this session
        MyStaticFloat.Value = 70;
    }
}
PreviousFWorldStaticVar<T>NextLogging

Last updated 5 months ago