ScalingGridSizes

ScalingGridSizes

#Overview

name: ScalingGridSizes

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

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of ScalingGridSizes is to define a set of grid sizes for scaling objects in the Unreal Engine editor viewport. This setting variable is primarily used for the editor’s grid snapping and scaling functionality.

ScalingGridSizes is primarily used by the Unreal Engine editor’s viewport system, specifically in the LevelEditorViewportSettings module. It is also utilized by the UVEditor plugin and the VR Editor.

The value of this variable is set in the ULevelEditorViewportSettings class, which is defined in the LevelEditorViewportSettings.h file. It is an array of float values, representing different grid sizes for scaling.

This variable interacts with other related variables such as CurrentScalingGridSize, which determines the currently selected grid size from the ScalingGridSizes array.

Developers should be aware that:

  1. The array should not be empty, as the engine prevents this to ensure there’s always a valid scaling grid size.
  2. The values in this array affect the scaling snap options available in the editor viewport.
  3. Changes to this variable trigger a PostEditChangeProperty function, which may affect the editor’s UI and functionality.

Best practices when using this variable include:

  1. Providing a range of useful scaling grid sizes that cover both fine and coarse adjustments.
  2. Ensuring the array is not left empty.
  3. Considering the needs of both percentage-based and unit-based scaling when setting these values.
  4. Updating related UI elements (like menus and toolbars) when modifying this variable to reflect the new scaling options.

#Setting Variables

#References In INI files

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

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

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

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

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

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

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

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

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Editor/UVEditor/Source/UVEditor/Private/SUVEditor2DViewportToolBar.cpp:405

Scope (from outer to inner):

file
function     TSharedRef<SWidget> SUVEditor2DViewportToolBar::FillScaleGridSnapMenu

Source code excerpt:

	ScaleGridMenuBuilder.BeginSection("ScaleSnapOptions", LOCTEXT("ScaleSnapOptions", "Scale Snap"));

	for (int32 CurGridAmountIndex = 0; CurGridAmountIndex < ViewportSettings->ScalingGridSizes.Num(); ++CurGridAmountIndex)
	{
		const float CurGridAmount = ViewportSettings->ScalingGridSizes[CurGridAmountIndex];

		FText MenuText;
		FText ToolTipText;

		if (GEditor->UsePercentageBasedScaling())
		{

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

Scope (from outer to inner):

file
class        class ULevelEditorViewportSettings : public UObject

Source code excerpt:

	/** Grid sizes for scaling */
	UPROPERTY(EditAnywhere, config, AdvancedDisplay, Category=GridSnapping)
	TArray<float> ScalingGridSizes;

	/** If enabled, actor positions will snap to the grid. */
	UPROPERTY(EditAnywhere, config, Category=GridSnapping, meta=(DisplayName = "Enable Grid Snapping"))
	uint32 GridEnabled:1;
	
	/** If enabled, actor rotations will snap to the grid. */

#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:925

Scope (from outer to inner):

file
function     TSharedRef<SWidget> STransformViewportToolBar::FillScaleGridSnapMenu

Source code excerpt:

	ScaleGridMenuBuilder.BeginSection("ScaleSnapOptions", LOCTEXT("ScaleSnapOptions", "Scale Snap"));

	for( int32 CurGridAmountIndex = 0; CurGridAmountIndex < ViewportSettings->ScalingGridSizes.Num(); ++CurGridAmountIndex )
	{
		const float CurGridAmount = ViewportSettings->ScalingGridSizes[ CurGridAmountIndex ];

		FText MenuText;
		FText ToolTipText;

		if( GEditor->UsePercentageBasedScaling() )
		{

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

Scope (from outer to inner):

file
function     void ULevelEditorViewportSettings::PostEditChangeProperty

Source code excerpt:

		int32* IndexRef = nullptr;

		if (Name == GET_MEMBER_NAME_CHECKED(ULevelEditorViewportSettings, ScalingGridSizes))
		{
			ArrayRef = &(ScalingGridSizes);
			IndexRef = &(CurrentScalingGridSize);
		}

		if (ArrayRef && IndexRef)
		{
			// Don't allow an empty array of grid sizes

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

Scope (from outer to inner):

file
function     void FVREditorActionCallbacks::OnScaleSnapSizeButtonClicked

Source code excerpt:

{
	const ULevelEditorViewportSettings* ViewportSettings = GetMutableDefault<ULevelEditorViewportSettings>();
	const int32 NumGridSizes = ViewportSettings->ScalingGridSizes.Num();

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

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