Revision Difference
ConVars#563207
<cat>Code.Input</cat>⤶
<title>ConVars</title>⤶
⤶
Console Variables (ConVars) are a great way to tweak and control game features or debugging tools dynamically during runtime. They can be defined and accessed through different types depending on where they are used.⤶
⤶
# Creating ConVars⤶
⤶
ConVars must be static.⤶
⤶
```⤶
[ConVar( "my_convar_name" )]⤶
public static float MyConVar { get; set; }⤶
```⤶
⤶
# Changing Values in-game⤶
⤶
Just like commands, ConVar values can be changed directly from the console by name, but they can also be run via ConsoleSystem.SetValue⤶
⤶
```csharp⤶
protected override void OnStart()⤶
{⤶
ConsoleSystem.SetValue( "my_convar_name", "hi!" );⤶
}⤶
```⤶
⤶
<warning>You can not change engine convars with ConsoleSystem.SetValue - you can only write to ConVars added by your game.</warning>