bAlwaysRefreshAllPreviews

bAlwaysRefreshAllPreviews

#Overview

name: bAlwaysRefreshAllPreviews

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

It is referenced in 9 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bAlwaysRefreshAllPreviews is to control the refresh behavior of material expression previews in the Unreal Engine Material Editor.

This setting variable is primarily used in the Material Editor subsystem of Unreal Engine, specifically within the FMaterialEditor class. It’s part of the editor functionality and not a runtime game feature.

The value of this variable is set in multiple places:

  1. It’s initialized to false in the FMaterialEditor constructor.
  2. It can be loaded from editor settings in the LoadEditorSettings() function.
  3. It can be toggled by the user through the OnAlwaysRefreshAllPreviews() function.
  4. It’s saved to editor settings in the SaveEditorSettings() function.

This variable interacts with the RefreshExpressionPreviews() function, which refreshes material expression previews. When bAlwaysRefreshAllPreviews is true, all previews are refreshed regardless of their individual settings.

Developers should be aware that setting this to true can potentially impact performance, especially with complex materials, as it forces all previews to refresh continuously.

Best practices when using this variable include:

  1. Use it judiciously, as constant refreshing of all previews can be resource-intensive.
  2. Consider the complexity of your materials when enabling this option.
  3. Remember to save the editor settings after changing this value if you want the change to persist between editor sessions.
  4. Be aware that this setting can be toggled by users in the editor UI, so don’t rely on it always being in a specific state in your code.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:487, section: [/Script/UnrealEd.MaterialEditorOptions]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/MaterialEditor/Private/MaterialEditor.cpp:897

Scope (from outer to inner):

file
function     FMaterialEditor::FMaterialEditor

Source code excerpt:

	, EditorOptions(nullptr)
	, ScopedTransaction(nullptr)
	, bAlwaysRefreshAllPreviews(false)
	, bHideUnusedConnectors(false)
	, bLivePreview(true)
	, bIsRealtime(false)
	, bShowBuiltinStats(false)
	, bHideUnrelatedNodes(false)
	, bLockNodeFadeState(false)

#Loc: <Workspace>/Engine/Source/Editor/MaterialEditor/Private/MaterialEditor.cpp:2498

Scope (from outer to inner):

file
function     void FMaterialEditor::LoadEditorSettings

Source code excerpt:

		ToggleLivePreview();
	}
	if (EditorOptions->bAlwaysRefreshAllPreviews) {OnAlwaysRefreshAllPreviews();}
	if (EditorOptions->bRealtimeExpressionViewport) {ToggleRealTimeExpressions();}

	if ( PreviewViewport.IsValid() )
	{
		if (EditorOptions->bShowGrid)
		{

#Loc: <Workspace>/Engine/Source/Editor/MaterialEditor/Private/MaterialEditor.cpp:2537

Scope (from outer to inner):

file
function     void FMaterialEditor::SaveEditorSettings

Source code excerpt:

		EditorOptions->bRealtimeMaterialViewport	= PreviewViewport->IsRealtime();
		EditorOptions->bHideUnusedConnectorsSetting	= IsOnHideConnectorsChecked();
		EditorOptions->bAlwaysRefreshAllPreviews	= IsOnAlwaysRefreshAllPreviews();
		EditorOptions->bRealtimeExpressionViewport	= IsToggleRealTimeExpressionsChecked();
		EditorOptions->bLivePreviewUpdate           = IsToggleLivePreviewChecked();
		EditorOptions->bHideUnrelatedNodes          = bHideUnrelatedNodes;
		EditorOptions->SaveConfig();
	}

#Loc: <Workspace>/Engine/Source/Editor/MaterialEditor/Private/MaterialEditor.cpp:3706

Scope (from outer to inner):

file
function     void FMaterialEditor::OnAlwaysRefreshAllPreviews

Source code excerpt:

void FMaterialEditor::OnAlwaysRefreshAllPreviews()
{
	bAlwaysRefreshAllPreviews = !bAlwaysRefreshAllPreviews;
	if ( bAlwaysRefreshAllPreviews )
	{
		RefreshExpressionPreviews();
	}
}

bool FMaterialEditor::IsOnAlwaysRefreshAllPreviews() const
{
	return bAlwaysRefreshAllPreviews == true;
}

void FMaterialEditor::ToggleHideUnrelatedNodes()
{
	TSharedPtr<SGraphEditor> FocusedGraphEd = FocusedGraphEdPtr.Pin();
	if (!FocusedGraphEd)

#Loc: <Workspace>/Engine/Source/Editor/MaterialEditor/Private/MaterialEditor.cpp:5876

Scope (from outer to inner):

file
function     void FMaterialEditor::ForceRefreshExpressionPreviews

Source code excerpt:

{
	// Initialize expression previews.
	const bool bOldAlwaysRefreshAllPreviews = bAlwaysRefreshAllPreviews;
	bAlwaysRefreshAllPreviews = true;
	RefreshExpressionPreviews();
	bAlwaysRefreshAllPreviews = bOldAlwaysRefreshAllPreviews;
}

void FMaterialEditor::AddToSelection(UMaterialExpression* Expression)
{
	if (TSharedPtr<SGraphEditor> FocusedGraphEd = FocusedGraphEdPtr.Pin())
	{

#Loc: <Workspace>/Engine/Source/Editor/MaterialEditor/Private/MaterialEditor.cpp:7188

Scope (from outer to inner):

file
function     void FMaterialEditor::RefreshExpressionPreviews

Source code excerpt:

	Material->UpdateCachedExpressionData();

	if ( bAlwaysRefreshAllPreviews || bForceRefreshAll)
	{
		// we need to make sure the rendering thread isn't drawing these tiles
		//SCOPED_SUSPEND_RENDERING_THREAD(true);

		// Refresh all expression previews.
		FMaterial::DeferredDeleteArray(ExpressionPreviews);

#Loc: <Workspace>/Engine/Source/Editor/MaterialEditor/Private/MaterialEditor.h:875

Scope (from outer to inner):

file
class        class FMaterialEditor : public IMaterialEditor, public FGCObject, public FTickableGameObject, public FEditorUndoClient, public FNotifyHook

Source code excerpt:


	/**
	 * Refreshes material expression previews.  Refreshes all previews if bAlwaysRefreshAllPreviews is true.
	 * Otherwise, refreshes only those previews that have a bRealtimePreview of true.
	 */
	void RefreshExpressionPreviews(bool bForceRefreshAll = false);

	/**
	 * Refreshes the preview for the specified material expression.  Does nothing if the specified expression
	 * has a bRealtimePreview of false.
	 *
	 * @param	MaterialExpression		The material expression to update.

#Loc: <Workspace>/Engine/Source/Editor/MaterialEditor/Private/MaterialEditor.h:990

Scope (from outer to inner):

file
class        class FMaterialEditor : public IMaterialEditor, public FGCObject, public FTickableGameObject, public FEditorUndoClient, public FNotifyHook

Source code excerpt:


	/** If true, always refresh all expression previews.  This overrides UMaterialExpression::bRealtimePreview. */
	bool bAlwaysRefreshAllPreviews;

	/** Material expression previews. */
	TArray<TRefCountPtr<FMatExpressionPreview>> ExpressionPreviews;

	/** Used to store material errors */
	TArray<TSharedPtr<FMaterialInfo>> MaterialInfoList;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Preferences/MaterialEditorOptions.h:44

Scope (from outer to inner):

file
class        class UMaterialEditorOptions : public UObject

Source code excerpt:

	/** If true, always refresh all expression previews. */
	UPROPERTY(EditAnywhere, config, Category=Options)
	uint32 bAlwaysRefreshAllPreviews:1;

	/** If false, use expression categorized menus. */
	UPROPERTY(EditAnywhere, config, Category=Options)
	uint32 bUseUnsortedMenus:1;

	/** The users favorite material expressions. */