StatColorMappings

StatColorMappings

#Overview

name: StatColorMappings

The value of this variable can be defined or overridden in .ini config files. 3 .ini config files referencing this setting variable.

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of StatColorMappings is to provide a customizable color mapping for displaying specific profiling statistics in Unreal Engine. This variable is primarily used for visualization and debugging purposes within the engine’s performance monitoring system.

StatColorMappings is primarily used by the Engine subsystem, as evidenced by its declaration in the UEngine class and its usage in the UnrealEngine.cpp file.

The value of this variable is set through global configuration, as indicated by the UPROPERTY(globalconfig) macro in its declaration. This means that the values can be modified in the engine’s configuration files without recompiling the code.

The StatColorMappings variable interacts with the GetStatValueColoration function, which uses the mappings to determine the appropriate color for a given statistic name and value.

Developers should be aware that:

  1. This variable is an array of FStatColorMapping structures, allowing for multiple stat-to-color mappings.
  2. The color mapping is used for visualization purposes and doesn’t affect the actual performance or functionality of the engine.
  3. Modifying these mappings will change how statistics are visually represented in debugging tools.

Best practices when using this variable include:

  1. Ensuring that the color mappings are intuitive and consistent across different statistics for easier interpretation.
  2. Regularly reviewing and updating the mappings to reflect any changes in performance metrics or debugging needs.
  3. Documenting any custom color mappings to maintain clarity for the development team.
  4. Using distinct color ranges for different types of statistics to improve readability and quick identification of performance issues.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:300, section: [/Script/Engine.Engine]

Location: <Workspace>/Engine/Config/BaseEngine.ini:301, section: [/Script/Engine.Engine]

Location: <Workspace>/Engine/Config/BaseEngine.ini:302, section: [/Script/Engine.Engine]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/Engine.h:1292

Scope (from outer to inner):

file
class        class UEngine : public UObject , public FExec

Source code excerpt:

	/** Colors used to display specific profiling stats */
	UPROPERTY(globalconfig)
	TArray<struct FStatColorMapping> StatColorMappings;

#if WITH_EDITORONLY_DATA
	/** A material used to render the sides of the builder brush/volumes/etc. */
	UPROPERTY()
	TObjectPtr<class UMaterial> EditorBrushMaterial;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/Engine.h:2554

Scope: file

Source code excerpt:

	}

	/** Uses StatColorMappings to find a color for this stat's value. */
	ENGINE_API bool GetStatValueColoration(const FString& StatName, float Value, FColor& OutColor);

	/** @return true if selection of translucent objects in perspective view ports is allowed */
	virtual bool AllowSelectTranslucent() const
	{
		// The editor may override this to disallow translucent selection based on user preferences

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:11091

Scope: file

Source code excerpt:

}

/** Uses StatColorMappings to find a color for this stat's value. */
bool UEngine::GetStatValueColoration(const FString& StatName, float Value, FColor& OutColor)
{
	for(const FStatColorMapping& Mapping : StatColorMappings)
	{
		if(StatName == Mapping.StatName)
		{
			const int32 NumPoints = Mapping.ColorMap.Num();

			// If no point in curve, return the Default value we passed in.