diff --git a/Source/Editor/Options/InterfaceOptions.cs b/Source/Editor/Options/InterfaceOptions.cs index 42f3a00d2..4cf1fe050 100644 --- a/Source/Editor/Options/InterfaceOptions.cs +++ b/Source/Editor/Options/InterfaceOptions.cs @@ -196,37 +196,19 @@ namespace FlaxEditor.Options [EditorDisplay("Interface"), EditorOrder(280), Tooltip("Editor content window orientation.")] public FlaxEngine.GUI.Orientation ContentWindowOrientation { get; set; } = FlaxEngine.GUI.Orientation.Horizontal; - private ValueFormattingType _valueFormatting = ValueFormattingType.None; - /// /// Gets or sets the formatting option for numeric values in the editor. /// [DefaultValue(ValueFormattingType.None)] - [EditorDisplay("Interface"), EditorOrder(300), Tooltip("Formatting of numeric values.")] - public ValueFormattingType ValueFormatting { - get => _valueFormatting; - set - { - _valueFormatting = value; - Units.UseUnitsFormatting = _valueFormatting != ValueFormattingType.None; - Units.AutomaticUnitsFormatting = _valueFormatting == ValueFormattingType.AutoUnit; - } - } - - private bool _spaceNumberAndUnits = false; + [EditorDisplay("Interface"), EditorOrder(300)] + public ValueFormattingType ValueFormatting { get; set; } /// /// Gets or sets the option to put a space between numbers and units for unit formatting. /// [DefaultValue(false)] - [EditorDisplay("Interface"), EditorOrder(310), Tooltip("Put a space between numbers and units.")] - public bool SpaceNumberAndUnits { get => _spaceNumberAndUnits; - set - { - _spaceNumberAndUnits = value; - Units.SpaceNumberAndUnits = _spaceNumberAndUnits; - } - } + [EditorDisplay("Interface"), EditorOrder(310)] + public bool SeparateValueAndUnit { get; set; } /// /// Gets or sets the timestamps prefix mode for output log messages. diff --git a/Source/Editor/Options/OptionsModule.cs b/Source/Editor/Options/OptionsModule.cs index 2dceb3400..debc0a663 100644 --- a/Source/Editor/Options/OptionsModule.cs +++ b/Source/Editor/Options/OptionsModule.cs @@ -200,6 +200,27 @@ namespace FlaxEditor.Options EditorAssets.Cache.OnEditorOptionsChanged(Options); + // Units formatting options + bool useUnitsFormatting = Options.Interface.ValueFormatting != InterfaceOptions.ValueFormattingType.None; + bool automaticUnitsFormatting = Options.Interface.ValueFormatting == InterfaceOptions.ValueFormattingType.AutoUnit; + bool separateValueAndUnit = Options.Interface.SeparateValueAndUnit; + if (useUnitsFormatting != Utilities.Units.UseUnitsFormatting || + automaticUnitsFormatting != Utilities.Units.AutomaticUnitsFormatting || + separateValueAndUnit != Utilities.Units.SeparateValueAndUnit) + { + Utilities.Units.UseUnitsFormatting = useUnitsFormatting; + Utilities.Units.AutomaticUnitsFormatting = automaticUnitsFormatting; + Utilities.Units.SeparateValueAndUnit = separateValueAndUnit; + + // Refresh UI in property panels + Editor.Windows.PropertiesWin?.Presenter.BuildLayoutOnUpdate(); + foreach (var window in Editor.Windows.Windows) + { + if (window is Windows.Assets.PrefabWindow prefabWindow) + prefabWindow.Presenter.BuildLayoutOnUpdate(); + } + } + // Send event OptionsChanged?.Invoke(Options); } diff --git a/Source/Editor/Utilities/Units.cs b/Source/Editor/Utilities/Units.cs index 4c4131337..64977c18b 100644 --- a/Source/Editor/Utilities/Units.cs +++ b/Source/Editor/Utilities/Units.cs @@ -20,7 +20,7 @@ public class Units /// /// Add a space between numbers and units for readability. /// - public static bool SpaceNumberAndUnits = true; + public static bool SeparateValueAndUnit = true; /// /// If set to true, the distance unit is chosen on the magnitude, otherwise it's meters. @@ -34,7 +34,7 @@ public class Units /// The formatted text. public static string Unit(string unit) { - if (SpaceNumberAndUnits) + if (SeparateValueAndUnit) return $" {unit}"; return unit; }