DistanceUnits

DistanceUnits

#Overview

name: DistanceUnits

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

#Summary

#Usage in the C++ source code

The purpose of DistanceUnits is to define the units of measurement for displaying distance and length values in the Unreal Engine editor. It allows developers to choose the preferred set of units for representing distances within the project.

This setting variable is primarily used by the Editor subsystem, specifically within the UnrealEd module. It is part of the EditorProjectAppearanceSettings, which controls various visual aspects of the editor.

The value of this variable is set through the editor’s project settings interface. It can be modified by users in the Editor Settings under the “Units” category. Internally, it is stored as a TArray, allowing for multiple unit types to be selected.

DistanceUnits interacts with other unit-related variables such as MassUnits, TimeUnits, AngleUnits, SpeedUnits, TemperatureUnits, and ForceUnits. Together, these variables define the unit display preferences for various physical quantities in the editor.

Developers should be aware that changing this variable affects how distance and length values are displayed throughout the editor. It does not change the underlying data, only its representation. This setting is project-specific and does not affect the game runtime.

Best practices when using this variable include:

  1. Choosing units that are most appropriate for the scale of your project (e.g., meters for human-scale environments, kilometers for large landscapes).
  2. Ensuring consistency with other unit choices to avoid confusion.
  3. Documenting the chosen units for team members to maintain consistency in asset creation and level design.
  4. Being mindful that this setting affects editor display only and does not impact in-game measurements or physics calculations.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEditor.ini:524, section: [/Script/UnrealEd.EditorProjectAppearanceSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/EditorProjectSettings.cpp:85

Scope (from outer to inner):

file
function     void UEditorProjectAppearanceSettings::PostEditChangeProperty

Source code excerpt:


	auto& Settings = FUnitConversion::Settings();
	if (Name == GET_MEMBER_NAME_CHECKED(UEditorProjectAppearanceSettings, DistanceUnits))
	{
		Settings.SetDisplayUnits(EUnitType::Distance, DistanceUnits);
	}
	else if (Name == GET_MEMBER_NAME_CHECKED(UEditorProjectAppearanceSettings, MassUnits))
	{
		Settings.SetDisplayUnits(EUnitType::Mass, MassUnits);
	}
	else if (Name == GET_MEMBER_NAME_CHECKED(UEditorProjectAppearanceSettings, TimeUnits))

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/EditorProjectSettings.cpp:158

Scope (from outer to inner):

file
function     void UEditorProjectAppearanceSettings::PostInitProperties

Source code excerpt:


	/** Setup the meta data for the array properties */
	SetupEnumMetaData(GetClass(), GET_MEMBER_NAME_CHECKED(UEditorProjectAppearanceSettings, DistanceUnits), TEXT("Micrometers, Millimeters, Centimeters, Meters, Kilometers, Inches, Feet, Yards, Miles"));
	SetupEnumMetaData(GetClass(), GET_MEMBER_NAME_CHECKED(UEditorProjectAppearanceSettings, MassUnits), TEXT("Micrograms, Milligrams, Grams, Kilograms, MetricTons,	Ounces, Pounds, Stones"));
	SetupEnumMetaData(GetClass(), GET_MEMBER_NAME_CHECKED(UEditorProjectAppearanceSettings, TimeUnits), TEXT("Milliseconds, Seconds, Minutes, Hours, Days, Months, Years"));

	if (UnitDisplay_DEPRECATED != EUnitDisplay::Invalid)
	{
		bDisplayUnits = UnitDisplay_DEPRECATED != EUnitDisplay::None;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/EditorProjectSettings.cpp:169

Scope (from outer to inner):

file
function     void UEditorProjectAppearanceSettings::PostInitProperties

Source code excerpt:

	if (DefaultInputUnits_DEPRECATED != EDefaultLocationUnit::Invalid)
	{
		DistanceUnits.Empty();
		DistanceUnits.Add(ConvertDefaultInputUnits(DefaultInputUnits_DEPRECATED));
	}

	auto& Settings = FUnitConversion::Settings();

	Settings.SetDisplayUnits(EUnitType::Distance, DistanceUnits);
	Settings.SetDisplayUnits(EUnitType::Mass, MassUnits);
	Settings.SetDisplayUnits(EUnitType::Time, TimeUnits);
	Settings.SetDisplayUnits(EUnitType::Angle, AngleUnits);
	Settings.SetDisplayUnits(EUnitType::Speed, SpeedUnits);
	Settings.SetDisplayUnits(EUnitType::Temperature, TemperatureUnits);
	Settings.SetDisplayUnits(EUnitType::Force, ForceUnits);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Public/Settings/EditorProjectSettings.h:75

Scope (from outer to inner):

file
class        class UEditorProjectAppearanceSettings : public UDeveloperSettings

Source code excerpt:


	UPROPERTY(EditAnywhere, config, Category=Units, AdvancedDisplay, meta=(DisplayName="Distance/Length", Tooltip="Choose a set of units in which to display distance/length values."))
	TArray<EUnit> DistanceUnits;

	UPROPERTY(EditAnywhere, config, Category=Units, AdvancedDisplay, meta=(DisplayName="Mass", Tooltip="Choose a set of units in which to display masses."))
	TArray<EUnit> MassUnits;

	UPROPERTY(EditAnywhere, config, Category=Units, AdvancedDisplay, meta=(DisplayName="Time", Tooltip="Choose the units in which to display time."))
	TArray<EUnit> TimeUnits;