console.position.x
console.position.x
#Overview
name: console.position.x
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Console X offset from left border \n
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of console.position.x is to control the horizontal position of the in-game console interface in Unreal Engine 5. This setting variable is used to adjust the X-axis offset of the console from the left border of the screen.
This setting variable is primarily used in the Engine module, specifically within the UserInterface subsystem for console rendering. It is referenced in the Console.cpp file, which is responsible for handling the in-game console functionality.
The value of this variable is set through a console command or configuration file. It is defined as a TAutoConsoleVariable with an initial value of 0, meaning the console will be positioned at the left edge of the screen by default.
The console.position.x variable interacts with other console-related variables, particularly console.position.y, which controls the vertical positioning of the console. Together, these variables allow for precise positioning of the console on the screen.
Developers should be aware that this variable is used in conjunction with the CVarCustomConsolePosEnabled variable. The custom positioning only takes effect when CVarCustomConsolePosEnabled is set to true.
Best practices for using this variable include:
- Use it in combination with console.position.y for complete control over console positioning.
- Ensure CVarCustomConsolePosEnabled is set to true when using custom positioning.
- Consider the screen resolution and UI scaling when setting values to ensure the console remains visible and accessible.
Regarding the associated variable CVarConsoleXPos:
The purpose of CVarConsoleXPos is to serve as the internal representation of the console.position.x setting within the engine’s code. It is a TAutoConsoleVariable that directly corresponds to the console.position.x setting.
CVarConsoleXPos is used in the Engine module, specifically in the Console rendering code. It is defined and used in the Console.cpp file.
The value of CVarConsoleXPos is set automatically based on the console.position.x setting. It is used in the PostRender_Console_Typing and PostRender_Console_Open functions to determine the left position of the console when rendering.
CVarConsoleXPos interacts closely with CVarConsoleYPos and CVarCustomConsolePosEnabled. These variables work together to control the console’s position on the screen.
Developers should be aware that CVarConsoleXPos is an internal variable and should generally not be modified directly. Instead, they should use the console.position.x setting to control the console’s horizontal position.
Best practices for CVarConsoleXPos include:
- Avoid modifying it directly; use console.position.x instead.
- When reading its value in code, use the GetValueOnAnyThread() method to ensure thread-safe access.
- Remember that its effect is only visible when CVarCustomConsolePosEnabled is true.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterface/Console.cpp:47
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarConsoleXPos(
TEXT("console.position.x"),
0,
TEXT("Console X offset from left border \n"),
ECVF_Default);
static TAutoConsoleVariable<int32> CVarConsoleYPos(
TEXT("console.position.y"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarConsoleXPos
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterface/Console.cpp:46
Scope: file
Source code excerpt:
ECVF_Default);
static TAutoConsoleVariable<int32> CVarConsoleXPos(
TEXT("console.position.x"),
0,
TEXT("Console X offset from left border \n"),
ECVF_Default);
static TAutoConsoleVariable<int32> CVarConsoleYPos(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterface/Console.cpp:1222
Scope (from outer to inner):
file
function void UConsole::PostRender_Console_Typing
Source code excerpt:
if (CVarCustomConsolePosEnabled.GetValueOnAnyThread())
{
LeftPos = (float)CVarConsoleXPos.GetValueOnAnyThread();
float BottomOffset = (float)CVarConsoleYPos.GetValueOnAnyThread();
ClipY = ClipY - BottomOffset;
}
PostRender_InputLine(Canvas, FIntPoint(LeftPos, ClipY));
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterface/Console.cpp:1320
Scope (from outer to inner):
file
function void UConsole::PostRender_Console_Open
Source code excerpt:
if (CVarCustomConsolePosEnabled.GetValueOnAnyThread())
{
LeftPos = (float)CVarConsoleXPos.GetValueOnAnyThread();
float BottomOffset = (float)CVarConsoleYPos.GetValueOnAnyThread();
Height = Canvas->ClipY - BottomOffset;
}
UFont* Font = GEngine->GetSmallFont();