Slate.UseFixedDeltaTime

Slate.UseFixedDeltaTime

#Overview

name: Slate.UseFixedDeltaTime

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 Slate.UseFixedDeltaTime is to control whether the Slate UI system uses a constant delta time for widget ticks. This setting is primarily used for the Slate UI rendering and update system within Unreal Engine.

This setting variable is utilized by the Slate subsystem, which is part of Unreal Engine’s UI framework. It’s also used in the FunctionalTesting module, specifically for UI screenshot testing.

The value of this variable is set through the console variable system. It’s defined as a static boolean (GSlateUseFixedDeltaTime) and linked to the console variable “Slate.UseFixedDeltaTime” using FAutoConsoleVariableRef.

This variable interacts with FSlateApplication::SetFixedDeltaTime() and FSlateApplication::GetFixedDeltaTime(). When enabled, it affects how delta time is calculated for Slate widget updates.

Developers must be aware that enabling this variable will make all Slate widget ticks use a constant delta time, which can affect the behavior and performance of UI elements. This can be particularly useful for testing and debugging, as it provides consistent update intervals regardless of actual frame rates.

Best practices when using this variable include:

  1. Use it primarily for testing and debugging purposes, not in production builds.
  2. When enabled, ensure that the fixed delta time (set via FSlateApplication::SetFixedDeltaTime()) is appropriate for your use case.
  3. Remember to reset it to its previous state after testing, as seen in the FunctionalUIScreenshotTest::EndPlay() function.
  4. Be cautious when using it in performance-critical scenarios, as it may not accurately represent real-world conditions.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Application/SlateApplication.cpp:113

Scope: file

Source code excerpt:

static bool GSlateUseFixedDeltaTime = false;
static FAutoConsoleVariableRef CVarSlateUseFixedDeltaTime(
	TEXT("Slate.UseFixedDeltaTime"),
	GSlateUseFixedDeltaTime,
	TEXT("True means we use a constant delta time on every widget tick.")
);
//////////////////////////////////////////////////////////////////////////

/** 

#Loc: <Workspace>/Engine/Source/Developer/FunctionalTesting/Private/FunctionalUIScreenshotTest.cpp:112

Scope (from outer to inner):

file
function     void AFunctionalUIScreenshotTest::PrepareTest

Source code excerpt:

	}
	NumTickPassed = 0;
	if (IConsoleVariable* CVarFixedDeltaTime = IConsoleManager::Get().FindConsoleVariable(TEXT("Slate.UseFixedDeltaTime")))
	{
		bWasPreviouslyUsingFixedDeltaTime = CVarFixedDeltaTime->GetBool();
		PreviousFixedDeltaTime = FSlateApplication::GetFixedDeltaTime();
		FSlateApplication::SetFixedDeltaTime(TestFixedDeltaTime);
		CVarFixedDeltaTime->SetWithCurrentPriority(true);
	}

#Loc: <Workspace>/Engine/Source/Developer/FunctionalTesting/Private/FunctionalUIScreenshotTest.cpp:158

Scope (from outer to inner):

file
function     void AFunctionalUIScreenshotTest::EndPlay

Source code excerpt:

	}

	if (IConsoleVariable* CVarFixedDeltaTime = IConsoleManager::Get().FindConsoleVariable(TEXT("Slate.UseFixedDeltaTime")))
	{
		CVarFixedDeltaTime->SetWithCurrentPriority(bWasPreviouslyUsingFixedDeltaTime);
		FSlateApplication::SetFixedDeltaTime(PreviousFixedDeltaTime);
	}
	NumTickPassed = 0;
}