CurrentScalingGridSize

CurrentScalingGridSize

#Overview

name: CurrentScalingGridSize

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 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of CurrentScalingGridSize is to control the current scale snapping grid size in the Unreal Engine 5 level editor viewport. It is used to determine the increments by which objects can be scaled in the editor.

This setting variable is primarily used by the Unreal Engine’s level editor subsystem, specifically in the viewport and transformation tools. It is part of the UnrealEd module, which is responsible for the editor’s functionality.

The value of this variable is set in several places:

  1. It can be configured through the editor settings, as indicated by the UPROPERTY(config) decorator in the ULevelEditorViewportSettings class.
  2. It is programmatically set in the UEditorEngine::SetScaleGridSize function, which clamps the value to a valid range.
  3. It can be modified through the VR editor interface, as seen in the FVREditorActionCallbacks::OnScaleSnapSizeButtonClicked function.

CurrentScalingGridSize interacts with the ScalingGridSizes array, which contains the available grid size options. The CurrentScalingGridSize serves as an index into this array to determine the actual scaling value to use.

Developers should be aware of the following when using this variable:

  1. The value is clamped between 0 and the size of the ScalingGridSizes array minus one.
  2. Changing this value will affect the snapping behavior when scaling objects in the level editor.
  3. It is part of the ULevelEditorViewportSettings, which means it affects all viewports in the level editor.

Best practices when using this variable include:

  1. Always use the provided setter functions (like SetScaleGridSize) to modify the value, as they ensure proper clamping and trigger necessary updates.
  2. Consider the needs of your level designers when choosing the range of available scaling grid sizes.
  3. Be mindful of how changes to this value might affect existing workflows or automated processes that rely on specific scaling behaviors.
  4. When accessing the value, use the getter functions (like GetScaleGridSize) to ensure you’re always working with the most up-to-date and properly processed value.

#Setting Variables

#References In INI files

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

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/LevelEditorViewportSettings.h:484

Scope (from outer to inner):

file
class        class ULevelEditorViewportSettings : public UObject

Source code excerpt:


	UPROPERTY(config)
	int32 CurrentScalingGridSize;

	UPROPERTY(config)
	bool PreserveNonUniformScale;

	/** Controls which array of rotation grid values we are using */
	UPROPERTY(config)

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorConstraints.cpp:126

Scope (from outer to inner):

file
function     float UEditorEngine::GetScaleGridSize

Source code excerpt:

	const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
	float ScaleVal = 0.0001f;
	if ( ViewportSettings->ScalingGridSizes.IsValidIndex(ViewportSettings->CurrentScalingGridSize) )
	{
		ScaleVal = ViewportSettings->ScalingGridSizes[ViewportSettings->CurrentScalingGridSize];
	}
	return ScaleVal;
}

void UEditorEngine::SetScaleGridSize( int32 InIndex )
{

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorConstraints.cpp:138

Scope (from outer to inner):

file
function     void UEditorEngine::SetScaleGridSize

Source code excerpt:


	ULevelEditorViewportSettings* ViewportSettings = GetMutableDefault<ULevelEditorViewportSettings>();
	ViewportSettings->CurrentScalingGridSize = FMath::Clamp<int32>( InIndex, 0, ViewportSettings->ScalingGridSizes.Num() - 1 );
	ViewportSettings->PostEditChange();

	RedrawLevelEditingViewports();
	FEditorSupportDelegates::UpdateUI.Broadcast();
}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/STransformViewportToolbar.cpp:762

Scope (from outer to inner):

file
function     bool STransformViewportToolBar::IsScaleGridSizeChecked

Source code excerpt:

{
	const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
	return (ViewportSettings->CurrentScalingGridSize == GridSizeIndex);
}

bool STransformViewportToolBar::IsLayer2DSelected(int32 LayerIndex)
{
	const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
	return (ViewportSettings->ActiveSnapLayerIndex == LayerIndex);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/SettingsClasses.cpp:1006

Scope (from outer to inner):

file
function     void ULevelEditorViewportSettings::PostEditChangeProperty

Source code excerpt:

		{
			ArrayRef = &(ScalingGridSizes);
			IndexRef = &(CurrentScalingGridSize);
		}

		if (ArrayRef && IndexRef)
		{
			// Don't allow an empty array of grid sizes
			if (ArrayRef->Num() == 0)

#Loc: <Workspace>/Engine/Source/Editor/VREditor/Private/VREditorActions.cpp:108

Scope (from outer to inner):

file
function     void FVREditorActionCallbacks::OnScaleSnapSizeButtonClicked

Source code excerpt:

	const int32 NumGridSizes = ViewportSettings->ScalingGridSizes.Num();

	const int32 CurrentGridSize = GetDefault<ULevelEditorViewportSettings>()->CurrentScalingGridSize;

	int32 NewGridSize = CurrentGridSize + 1;
	if (NewGridSize >= NumGridSizes)
	{
		NewGridSize = 0;
	}