LevelInstance.ForceEditorWorldMode
LevelInstance.ForceEditorWorldMode
#Overview
name: LevelInstance.ForceEditorWorldMode
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allow -game instances to behave like an editor with temporary root object attached to instance. This will prevent HLOD from working in -game. This feature is only supported on non WP worlds.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of LevelInstance.ForceEditorWorldMode is to allow game instances to behave like an editor with temporary root objects attached to instances. This setting is primarily used in the level instance and streaming system of Unreal Engine 5.
This setting variable is relied upon by the Unreal Engine’s level streaming subsystem, specifically within the LevelInstance module. It’s also referenced in the ConcertSyncClient plugin, which is part of the Concert collaboration system.
The value of this variable is set through a console variable (CVar) system. It’s initialized as a static boolean variable GForceEditorWorldMode
and then bound to the console variable “LevelInstance.ForceEditorWorldMode” using FAutoConsoleVariableRef.
The associated variable that interacts with LevelInstance.ForceEditorWorldMode is GForceEditorWorldMode. They share the same value and are used interchangeably in the code.
Developers must be aware of several important points when using this variable:
- Enabling this feature will prevent HLOD (Hierarchical Level of Detail) from working in game mode.
- This feature is only supported on non-World Partition worlds.
- It’s designed to be used in non-editor (game) contexts, as indicated by the check
if (GForceEditorWorldMode && !GIsEditor)
.
Best practices when using this variable include:
- Only enable it when necessary, as it can impact performance and functionality (like HLOD).
- Be cautious when using it in World Partition enabled worlds, as it’s not supported there.
- Consider the implications on level streaming and instance behavior when enabled.
Regarding the associated variable GForceEditorWorldMode:
The purpose of GForceEditorWorldMode is to internally represent the state set by LevelInstance.ForceEditorWorldMode. It’s used directly in the C++ code to control behavior based on this setting.
This variable is used within the LevelStreamingLevelInstance system, specifically in the IsEditorWorldMode() function. It determines whether the current world should behave like an editor world, even in game mode.
The value of GForceEditorWorldMode is set by the console variable system when LevelInstance.ForceEditorWorldMode is modified.
Developers should be aware that this variable directly affects the behavior of level instances and should be used carefully, considering its impact on world behavior and performance.
Best practices for GForceEditorWorldMode include:
- Avoid modifying it directly; instead, use the LevelInstance.ForceEditorWorldMode console variable.
- Be aware of its state when working with level instances, especially in game contexts.
- Consider its interaction with other systems like World Partition and HLOD when enabled.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LevelInstance/LevelInstanceLevelStreaming.cpp:38
Scope: file
Source code excerpt:
static bool GForceEditorWorldMode = false;
FAutoConsoleVariableRef CVarForceEditorWorldMode(
TEXT("LevelInstance.ForceEditorWorldMode"),
GForceEditorWorldMode,
TEXT("Allow -game instances to behave like an editor with temporary root object attached to instance. This will prevent HLOD from working in -game. This feature is only supported on non WP worlds."),
ECVF_Default);
namespace FLevelInstanceLevelStreamingUtils
#Loc: <Workspace>/Engine/Plugins/Developer/Concert/ConcertSync/ConcertSyncClient/Source/ConcertSyncClient/Private/ConcertClientWorkspace.cpp:183
Scope (from outer to inner):
file
namespace UE::ConcertWorkspace::Private
Source code excerpt:
static FCVarBool<TEXT("Editor.ReflectEditorLevelVisibilityWithGame"), true /*Editor Only*/> ReflectVisInGame;
static FCVarBool<TEXT("LevelInstance.ForceEditorWorldMode"), false /*Editor Only*/> LevelInstanceForceEditorWorldMode;
static FCVarBool<TEXT("EditorPaths.Enabled"), false /*Editor Only*/> EditorPaths;
}
struct FConcertWorkspaceConsoleCommands
{
FConcertWorkspaceConsoleCommands() :
#Associated Variable and Callsites
This variable is associated with another variable named GForceEditorWorldMode
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LevelInstance/LevelInstanceLevelStreaming.cpp:36
Scope: file
Source code excerpt:
ECVF_Default);
static bool GForceEditorWorldMode = false;
FAutoConsoleVariableRef CVarForceEditorWorldMode(
TEXT("LevelInstance.ForceEditorWorldMode"),
GForceEditorWorldMode,
TEXT("Allow -game instances to behave like an editor with temporary root object attached to instance. This will prevent HLOD from working in -game. This feature is only supported on non WP worlds."),
ECVF_Default);
namespace FLevelInstanceLevelStreamingUtils
{
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/LevelInstance/LevelInstanceLevelStreaming.cpp:88
Scope (from outer to inner):
file
function bool ULevelStreamingLevelInstance::IsEditorWorldMode
Source code excerpt:
{
bool bCanSupportForceEditorWorldMode = !GIsEditor;
if (GForceEditorWorldMode && !GIsEditor)
{
UWorld* OwningWorld = GetWorld();
check(OwningWorld);
// We do not support GForceEditorWorldMode in WP worlds.
if (OwningWorld->GetWorldPartition() != nullptr)
{
bCanSupportForceEditorWorldMode = false;
}
}
return (GForceEditorWorldMode && bCanSupportForceEditorWorldMode) || !GetWorld()->IsGameWorld();
}
TOptional<FFolder::FRootObject> ULevelStreamingLevelInstance::GetFolderRootObject() const
{
if (ILevelInstanceInterface* LevelInstance = GetLevelInstance())
{