Editor.AsyncStaticMeshPlayInEditorMode

Editor.AsyncStaticMeshPlayInEditorMode

#Overview

name: Editor.AsyncStaticMeshPlayInEditorMode

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of Editor.AsyncStaticMeshPlayInEditorMode is to control how static meshes are handled when entering Play-In-Editor (PIE) mode in Unreal Engine 5. This setting variable affects the performance and visual fidelity during the transition from editor to play mode.

This setting variable is primarily used by the Static Mesh Compiler subsystem within the Engine module. It’s specifically utilized in the StaticMeshCompiler.cpp file, which is responsible for managing the compilation of static meshes.

The value of this variable is set through a console variable (CVarAsyncStaticMeshPlayInEditorMode) with three possible options: 0 - Wait for all static meshes to be built before entering PIE (slowest, but most accurate) 1 - Wait only for static meshes affecting navigation and physics (faster, with potential visual artifacts) 2 - Wait only for nearby static meshes affecting navigation and physics (fastest, with potential issues farther from the player)

This variable interacts closely with the static mesh compilation process and affects how the engine prioritizes mesh building when transitioning to PIE mode.

Developers should be aware that:

  1. Lower values provide more accurate representations but slower PIE entry times.
  2. Higher values offer faster PIE entry but may result in visual or gameplay artifacts.
  3. The setting directly impacts the player’s experience during development and testing.

Best practices when using this variable include:

  1. Use setting 0 for final testing and when preparing builds for release.
  2. Use setting 1 or 2 during active development to speed up iteration times.
  3. Be aware of potential visual or physics issues when using settings 1 or 2, especially when testing gameplay elements that rely on distant static meshes.

Regarding the associated variable CVarAsyncStaticMeshPlayInEditorMode:

This is the actual console variable that stores and manages the Editor.AsyncStaticMeshPlayInEditorMode setting. It’s defined using TAutoConsoleVariable, which allows it to be changed at runtime through the console.

The purpose of CVarAsyncStaticMeshPlayInEditorMode is to provide a programmatic interface for getting and setting the AsyncStaticMeshPlayInEditorMode value within the engine’s C++ code.

This variable is used directly in the FStaticMeshCompilingManager::FinishCompilationsForGame function to determine how to handle static mesh compilations when entering PIE mode.

Developers should be aware that:

  1. Changes to this variable take effect immediately and can be made through the console or code.
  2. The variable’s value is retrieved using GetValueOnGameThread(), ensuring thread-safe access.

Best practices for using CVarAsyncStaticMeshPlayInEditorMode include:

  1. Use it for runtime adjustments during development and debugging.
  2. Consider exposing it in the editor UI for easier tweaking during development.
  3. Be cautious about changing its value in shipping builds, as it may affect performance and gameplay.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshCompiler.cpp:34

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarAsyncStaticMeshPlayInEditorMode(
	TEXT("Editor.AsyncStaticMeshPlayInEditorMode"),
	0,
	TEXT("0 - Wait until all static meshes are built before entering PIE. (Slowest but causes no visual or behavior artifacts.) \n")
	TEXT("1 - Wait until all static meshes affecting navigation and physics are built before entering PIE. (Some visuals might be missing during compilation.)\n")
	TEXT("2 - Wait only on static meshes affecting navigation and physics when they are close to the player. (Fastest while still preventing falling through the floor and going through objects.)\n"),
	ECVF_Default);

#Associated Variable and Callsites

This variable is associated with another variable named CVarAsyncStaticMeshPlayInEditorMode. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshCompiler.cpp:33

Scope: file

Source code excerpt:

	));

static TAutoConsoleVariable<int32> CVarAsyncStaticMeshPlayInEditorMode(
	TEXT("Editor.AsyncStaticMeshPlayInEditorMode"),
	0,
	TEXT("0 - Wait until all static meshes are built before entering PIE. (Slowest but causes no visual or behavior artifacts.) \n")
	TEXT("1 - Wait until all static meshes affecting navigation and physics are built before entering PIE. (Some visuals might be missing during compilation.)\n")
	TEXT("2 - Wait only on static meshes affecting navigation and physics when they are close to the player. (Fastest while still preventing falling through the floor and going through objects.)\n"),
	ECVF_Default);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StaticMeshCompiler.cpp:434

Scope (from outer to inner):

file
function     void FStaticMeshCompilingManager::FinishCompilationsForGame

Source code excerpt:

			TRACE_CPUPROFILER_EVENT_SCOPE(FStaticMeshCompilingManager::FinishCompilationsForGame);

			const int32 PlayInEditorMode = CVarAsyncStaticMeshPlayInEditorMode.GetValueOnGameThread();
			
			const bool bShowDebugDraw = CVarAsyncStaticMeshDebugDraw.GetValueOnGameThread();

			TSet<const UWorld*> PIEWorlds;
			TMultiMap<const UWorld*, FBoxSphereBounds> WorldActors;