Daily Unreal Column #85 - Console Variable Sink
Using console variable to manage different aspects of your game is great, but sometimes you also want to be explicitly notified when a console variable value changes.
This is exactly what FAutoConsoleVariableSink
is for. It allows us to bind a function to an existing console variable and be notified whenever its updated.
FAutoConsoleVariableSink
are usually defined in a source file (not headers) and look like this:
FAutoConsoleVariableSink FooCVarSink(FConsoleCommandDelegate::CreateStatic(&OnFooCVarChanged));
As you can see, the constructor of this property take a delegate reference. This is where we define a function we want to invoke when a console variable changes.
There are multiple examples in the engine on how these are being utilized, so if you are curious, have a look at the engine code.