SnapScaleEnabled
SnapScaleEnabled
#Overview
name: SnapScaleEnabled
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 SnapScaleEnabled is to control whether actor sizes will snap to the grid in the Unreal Engine editor’s viewport. This setting is primarily used for level editing and actor manipulation within the editor.
This setting variable is primarily used by the Level Editor subsystem of Unreal Engine, specifically in the viewport interaction and manipulation tools. It’s referenced in several modules including LevelEditor, UnrealEd, and VREditor.
The value of this variable is set in the ULevelEditorViewportSettings class, which is a configuration class for Level Editor viewport settings. It can be toggled through various editor actions and UI elements, such as toolbar buttons or menu items.
SnapScaleEnabled interacts with other snapping and grid-related variables, such as GridEnabled for location snapping and ScalingGridSizes for determining the snap increments.
Developers should be aware that this variable affects the behavior of scaling operations in the viewport. When enabled, it forces actor scaling to align with the grid, which can be useful for precise positioning but may also limit fine-grained control.
Best practices when using this variable include:
- Providing a clear way for users to toggle this setting in the editor UI.
- Considering the appropriate grid size when this setting is enabled, as it directly affects the granularity of scaling operations.
- Ensuring that the snapping behavior is consistent across different editor tools and modes that involve scaling.
- Documenting the behavior for end-users, especially level designers, so they understand how it affects their workflow.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:416, section: [/Script/UnrealEd.LevelEditorViewportSettings]
- INI Section:
/Script/UnrealEd.LevelEditorViewportSettings
- Raw value:
True
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Editor/LevelEditor/Private/Elements/Component/ComponentElementLevelEditorViewportInteractionCustomization.cpp:192
Scope (from outer to inner):
file
function void FComponentElementLevelEditorViewportInteractionCustomization::ValidateScale
lambda-function
Source code excerpt:
int32 MaxAxisIndex = -1;
const ULevelEditorViewportSettings* ViewportSettings = GetDefault<ULevelEditorViewportSettings>();
bool SnapScaleAfter = ViewportSettings->SnapScaleEnabled;
//Found the number of active axis
//Found if we have to swap some sign
for (int Axis = 0; Axis < 3; ++Axis)
{
if (bActiveAxes[Axis])
#Loc: <Workspace>/Engine/Source/Editor/LevelEditor/Private/Elements/Component/ComponentElementLevelEditorViewportInteractionCustomization.cpp:254
Scope (from outer to inner):
file
function void FComponentElementLevelEditorViewportInteractionCustomization::ValidateScale
lambda-function
Source code excerpt:
FVector::FReal AbsoluteScaleValue = InOriginalPreDragScale[MaxAxisIndex] + InOutScaleDelta[MaxAxisIndex];
if (ViewportSettings->SnapScaleEnabled)
{
AbsoluteScaleValue = FMath::GridSnap(InOriginalPreDragScale[MaxAxisIndex] + InOutScaleDelta[MaxAxisIndex], (FVector::FReal)GEditor->GetScaleGridSize());
SnapScaleAfter = false;
}
FVector::FReal ScaleRatioMax = AbsoluteScaleValue / InOriginalPreDragScale[MaxAxisIndex];
#Loc: <Workspace>/Engine/Source/Editor/LevelEditor/Private/LevelEditorActions.cpp:2199
Scope (from outer to inner):
file
function void FLevelEditorActionCallbacks::ScaleGridSnap_Clicked
Source code excerpt:
void FLevelEditorActionCallbacks::ScaleGridSnap_Clicked()
{
GUnrealEd->Exec( GetWorld(), *FString::Printf( TEXT("MODE SCALEGRID=%d"), !GetDefault<ULevelEditorViewportSettings>()->SnapScaleEnabled ? 1 : 0 ) );
}
bool FLevelEditorActionCallbacks::ScaleGridSnap_IsChecked()
{
return GetDefault<ULevelEditorViewportSettings>()->SnapScaleEnabled;
}
bool FLevelEditorActionCallbacks::SaveAnimationFromSkeletalMeshComponent(AActor * EditorActor, AActor * SimActor, TArray<USkeletalMeshComponent*> & OutEditorComponents)
{
FLevelEditorModule& LevelEditorModule = FModuleManager::GetModuleChecked<FLevelEditorModule>( TEXT("LevelEditor") );
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/LevelEditorViewportSettings.h:437
Scope (from outer to inner):
file
class class ULevelEditorViewportSettings : public UObject
Source code excerpt:
/** If enabled, actor sizes will snap to the grid. */
UPROPERTY(EditAnywhere, config, Category=GridSnapping, meta=(DisplayName = "Enable Scale Snapping"))
uint32 SnapScaleEnabled:1;
/** If enabled, actors will snap to surfaces in the viewport when dragged around */
UPROPERTY(config)
FSnapToSurfaceSettings SnapToSurface;
private:
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/STransformViewportToolbar.cpp:1002
Scope (from outer to inner):
file
function ECheckBoxState STransformViewportToolBar::IsScaleGridSnapChecked
Source code excerpt:
ECheckBoxState STransformViewportToolBar::IsScaleGridSnapChecked() const
{
return GetDefault<ULevelEditorViewportSettings>()->SnapScaleEnabled ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
}
void STransformViewportToolBar::HandleToggleLocationGridSnap( ECheckBoxState InState )
{
GUnrealEd->Exec( GEditor->GetEditorWorldContext().World(), *FString::Printf( TEXT("MODE GRID=%d"), !GetDefault<ULevelEditorViewportSettings>()->GridEnabled ? 1 : 0 ) );
}
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/STransformViewportToolbar.cpp:1033
Scope (from outer to inner):
file
function void STransformViewportToolBar::HandleToggleScaleGridSnap
Source code excerpt:
void STransformViewportToolBar::HandleToggleScaleGridSnap(ECheckBoxState InState)
{
GUnrealEd->Exec( GEditor->GetEditorWorldContext().World(), *FString::Printf( TEXT("MODE SCALEGRID=%d"), !GetDefault<ULevelEditorViewportSettings>()->SnapScaleEnabled ? 1 : 0 ) );
}
#undef LOCTEXT_NAMESPACE
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/SnappingUtils.cpp:121
Scope (from outer to inner):
file
function bool FEditorViewportSnapping::IsSnapScaleEnabled
Source code excerpt:
bool FEditorViewportSnapping::IsSnapScaleEnabled()
{
return GetDefault<ULevelEditorViewportSettings>()->SnapScaleEnabled;
}
bool FEditorViewportSnapping::IsSnapToVertexEnabled(bool bIsPivot)
{
if( GetDefault<ULevelEditorViewportSettings>()->bSnapVertices )
{
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/UnrealEdSrv.cpp:3047
Scope (from outer to inner):
file
function bool UUnrealEdEngine::Exec_Mode
Source code excerpt:
ULevelEditorViewportSettings* ViewportSettings = GetMutableDefault<ULevelEditorViewportSettings>();
ViewportSettings->SnapScaleEnabled = DWord1;
ViewportSettings->PostEditChange();
FEditorSupportDelegates::UpdateUI.Broadcast();
}
if( FParse::Value(Str, TEXT("SNAPVERTEX="), DWord1) )
#Loc: <Workspace>/Engine/Source/Editor/VREditor/Private/VREditorActions.cpp:100
Scope (from outer to inner):
file
function ECheckBoxState FVREditorActionCallbacks::GetScaleSnapState
Source code excerpt:
ECheckBoxState FVREditorActionCallbacks::GetScaleSnapState()
{
return GetDefault<ULevelEditorViewportSettings>()->SnapScaleEnabled ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
}
void FVREditorActionCallbacks::OnScaleSnapSizeButtonClicked()
{
const ULevelEditorViewportSettings* ViewportSettings = GetMutableDefault<ULevelEditorViewportSettings>();
const int32 NumGridSizes = ViewportSettings->ScalingGridSizes.Num();