How to read and write the hidden DisplayGamma variable in UDK.

April 23, 2013

Reading and Writing the Gamma Display Setting in UDK

Many UDK developers may know the console command "Gamma [FLOAT]" but as most of you know, the gamma value is never saved(resets after game restart). However this can be easily saved without having to mirror the gamma value in your GUI. It is indeed possible to read the gamma value stored in the engine by accessing the Client class. This class is grouped under Engine but yet if you look for it in the Engine/Classes folder you can't seem to find the Client class yet you can access its variables.


The UDK has hunderds if not thousands of classes that are available in any of the UnrealScript folders, this is because most classes are declared in C++ and therefore are within the game's executable. But yet you can access them because when the engine launches, it registers most of those C++ classes as UnrealScript classes(Well imagine that...) and therefore before the engine compiles your code it'll be aware of the Client class because it was already registered before compiling anything!

The code

The class Client is the C++ registered class we'll need in order to read the game's gamma and save it.


This class has the following variables that can be accessed through UnrealScript:

  • DisplayGamma : Float
  • MinDesiredFrameRate : Float
  • InitialButtonRepeatDelay : Float
  • ButtonRepeatDelay : Float

Obviously the DisplayGamma variable is the one we need. So let's write(copy for you) the code!


The reading one is fairly simple yet most don't know of its existence so it's worth a tutorial:

final function float GetGamma()
    return class'Client'.default.DisplayGamma;


The writing function is a bit longer and you might want to adjust it depending on your needs:

final function SetGamma( float newGamma )
    // Change Run-Time Gamma
    ConsoleCommand( "Gamma" @ newGamma );
    // Change Save-Time Gamma
    class'Client'.default.DisplayGamma = newGamma;

The important thing you need to know above is that you have to both call the Gamma command and as well set the DisplayGamma property because the console command apparently does not change the DisplayGamme's value by itself.


StaticSaveConfig() is called so that we can read the up-to-date DisplayGamma value the next time the game gets launched.

How did I find these variables?

Pretty simple although unknown, open up the BaseEngine.ini and look for [Engine.Client] this means the variables below it are for the class Client which resists in package Engine yet the class doesn't exist there as I said before. But nonetheless this lets you know what variables you can access in UnrealScript even when they are not declared there! This trick can be used for many other classes unless no package is specified such as [SystemSettings] that one won't work unfortunalely, but anyway there's a console command for that one, so all is good :)


Another example: `Log( class'System'.default.Suppress[0] ); works ;)