diff --git a/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs b/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs index 88ce53b78..3794bffc8 100644 --- a/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs +++ b/Source/Editor/CustomEditors/Editors/ActorTransformEditor.cs @@ -111,14 +111,17 @@ namespace FlaxEditor.CustomEditors.Editors SetLinkStyle(); var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(LinkedLabel.Text.Value); _linkButton.LocalX += textSize.X + 10; - LinkedLabel.SetupContextMenu += (label, menu, editor) => + if (LinkedLabel != null) { - menu.AddSeparator(); - if (LinkValues) - menu.AddButton("Unlink", ToggleLink).LinkTooltip("Unlinks scale components from uniform scaling"); - else - menu.AddButton("Link", ToggleLink).LinkTooltip("Links scale components for uniform scaling"); - }; + LinkedLabel.SetupContextMenu += (label, menu, editor) => + { + menu.AddSeparator(); + if (LinkValues) + menu.AddButton("Unlink", ToggleLink).LinkTooltip("Unlinks scale components from uniform scaling"); + else + menu.AddButton("Link", ToggleLink).LinkTooltip("Links scale components for uniform scaling"); + }; + } // Override colors var back = FlaxEngine.GUI.Style.Current.TextBoxBackground; diff --git a/Source/Editor/CustomEditors/Editors/DoubleEditor.cs b/Source/Editor/CustomEditors/Editors/DoubleEditor.cs index 2049860c6..906e6fff0 100644 --- a/Source/Editor/CustomEditors/Editors/DoubleEditor.cs +++ b/Source/Editor/CustomEditors/Editors/DoubleEditor.cs @@ -34,13 +34,16 @@ namespace FlaxEditor.CustomEditors.Editors if (valueCategory != Utils.ValueCategory.None) { doubleValue.SetCategory(valueCategory); - LinkedLabel.SetupContextMenu += (label, menu, editor) => + if (LinkedLabel != null) { - menu.AddSeparator(); - var mb = menu.AddButton("Show formatted", bt => { doubleValue.SetCategory(bt.Checked ? valueCategory : Utils.ValueCategory.None); }); - mb.AutoCheck = true; - mb.Checked = doubleValue.ValueBox.Category != Utils.ValueCategory.None; - }; + LinkedLabel.SetupContextMenu += (label, menu, editor) => + { + menu.AddSeparator(); + var mb = menu.AddButton("Show formatted", bt => { doubleValue.SetCategory(bt.Checked ? valueCategory : Utils.ValueCategory.None); }); + mb.AutoCheck = true; + mb.Checked = doubleValue.ValueBox.Category != Utils.ValueCategory.None; + }; + } } } } diff --git a/Source/Editor/CustomEditors/Editors/FloatEditor.cs b/Source/Editor/CustomEditors/Editors/FloatEditor.cs index 9d3ff1490..85f8bb5a3 100644 --- a/Source/Editor/CustomEditors/Editors/FloatEditor.cs +++ b/Source/Editor/CustomEditors/Editors/FloatEditor.cs @@ -40,7 +40,7 @@ namespace FlaxEditor.CustomEditors.Editors _element = slider; return; } - + var floatValue = layout.FloatValue(); floatValue.ValueBox.ValueChanged += OnValueChanged; floatValue.ValueBox.SlidingEnd += ClearToken; @@ -53,13 +53,16 @@ namespace FlaxEditor.CustomEditors.Editors if (valueCategory != Utils.ValueCategory.None) { floatValue.SetCategory(valueCategory); - LinkedLabel.SetupContextMenu += (label, menu, editor) => + if (LinkedLabel != null) { - menu.AddSeparator(); - var mb = menu.AddButton("Show formatted", bt => { floatValue.SetCategory(bt.Checked ? valueCategory : Utils.ValueCategory.None); }); - mb.AutoCheck = true; - mb.Checked = floatValue.ValueBox.Category != Utils.ValueCategory.None; - }; + LinkedLabel.SetupContextMenu += (label, menu, editor) => + { + menu.AddSeparator(); + var mb = menu.AddButton("Show formatted", bt => { floatValue.SetCategory(bt.Checked ? valueCategory : Utils.ValueCategory.None); }); + mb.AutoCheck = true; + mb.Checked = floatValue.ValueBox.Category != Utils.ValueCategory.None; + }; + } } } } diff --git a/Source/Editor/CustomEditors/Editors/InputEditor.cs b/Source/Editor/CustomEditors/Editors/InputEditor.cs index 3521f35a5..5a4905206 100644 --- a/Source/Editor/CustomEditors/Editors/InputEditor.cs +++ b/Source/Editor/CustomEditors/Editors/InputEditor.cs @@ -22,7 +22,8 @@ namespace FlaxEditor.CustomEditors.Editors /// public override void Initialize(LayoutElementsContainer layout) { - LinkedLabel.SetupContextMenu += OnSetupContextMenu; + if (LinkedLabel != null) + LinkedLabel.SetupContextMenu += OnSetupContextMenu; var comboBoxElement = layout.ComboBox(); _comboBox = comboBoxElement.ComboBox; var names = new List(); diff --git a/Source/Editor/CustomEditors/Editors/QuaternionEditor.cs b/Source/Editor/CustomEditors/Editors/QuaternionEditor.cs index 7712f1a08..96f9d0646 100644 --- a/Source/Editor/CustomEditors/Editors/QuaternionEditor.cs +++ b/Source/Editor/CustomEditors/Editors/QuaternionEditor.cs @@ -59,12 +59,15 @@ namespace FlaxEditor.CustomEditors.Editors ZElement.ValueBox.ValueChanged += OnValueChanged; ZElement.ValueBox.SlidingEnd += ClearToken; - LinkedLabel.SetupContextMenu += (label, menu, editor) => + if (LinkedLabel != null) { - menu.AddSeparator(); - var value = ((Quaternion)Values[0]).EulerAngles; - menu.AddButton("Copy Euler", () => { Clipboard.Text = JsonSerializer.Serialize(value); }).TooltipText = "Copy the Euler Angles in Degrees"; - }; + LinkedLabel.SetupContextMenu += (label, menu, editor) => + { + menu.AddSeparator(); + var value = ((Quaternion)Values[0]).EulerAngles; + menu.AddButton("Copy Euler", () => { Clipboard.Text = JsonSerializer.Serialize(value); }).TooltipText = "Copy the Euler Angles in Degrees"; + }; + } } private void OnValueChanged() diff --git a/Source/Editor/CustomEditors/Editors/Vector3Editor.cs b/Source/Editor/CustomEditors/Editors/Vector3Editor.cs index e7170a22d..719fbf05d 100644 --- a/Source/Editor/CustomEditors/Editors/Vector3Editor.cs +++ b/Source/Editor/CustomEditors/Editors/Vector3Editor.cs @@ -96,18 +96,22 @@ namespace FlaxEditor.CustomEditors.Editors ZElement.SetCategory(category); ZElement.ValueBox.ValueChanged += OnZValueChanged; ZElement.ValueBox.SlidingEnd += ClearToken; - LinkedLabel.SetupContextMenu += (label, menu, editor) => + + if (LinkedLabel != null) { - menu.AddSeparator(); - var mb = menu.AddButton("Show formatted", bt => + LinkedLabel.SetupContextMenu += (label, menu, editor) => { - XElement.SetCategory(bt.Checked ? category : Utils.ValueCategory.None); - YElement.SetCategory(bt.Checked ? category : Utils.ValueCategory.None); - ZElement.SetCategory(bt.Checked ? category : Utils.ValueCategory.None); - }); - mb.AutoCheck = true; - mb.Checked = XElement.ValueBox.Category != Utils.ValueCategory.None; - }; + menu.AddSeparator(); + var mb = menu.AddButton("Show formatted", bt => + { + XElement.SetCategory(bt.Checked ? category : Utils.ValueCategory.None); + YElement.SetCategory(bt.Checked ? category : Utils.ValueCategory.None); + ZElement.SetCategory(bt.Checked ? category : Utils.ValueCategory.None); + }); + mb.AutoCheck = true; + mb.Checked = XElement.ValueBox.Category != Utils.ValueCategory.None; + }; + } } private void OnXValueChanged() @@ -294,18 +298,22 @@ namespace FlaxEditor.CustomEditors.Editors ZElement.SetCategory(category); ZElement.ValueBox.ValueChanged += OnValueChanged; ZElement.ValueBox.SlidingEnd += ClearToken; - LinkedLabel.SetupContextMenu += (label, menu, editor) => + + if (LinkedLabel != null) { - menu.AddSeparator(); - var mb = menu.AddButton("Show formatted", bt => + LinkedLabel.SetupContextMenu += (label, menu, editor) => { - XElement.SetCategory(bt.Checked ? category : Utils.ValueCategory.None); - YElement.SetCategory(bt.Checked ? category : Utils.ValueCategory.None); - ZElement.SetCategory(bt.Checked ? category : Utils.ValueCategory.None); - }); - mb.AutoCheck = true; - mb.Checked = XElement.ValueBox.Category != Utils.ValueCategory.None; - }; + menu.AddSeparator(); + var mb = menu.AddButton("Show formatted", bt => + { + XElement.SetCategory(bt.Checked ? category : Utils.ValueCategory.None); + YElement.SetCategory(bt.Checked ? category : Utils.ValueCategory.None); + ZElement.SetCategory(bt.Checked ? category : Utils.ValueCategory.None); + }); + mb.AutoCheck = true; + mb.Checked = XElement.ValueBox.Category != Utils.ValueCategory.None; + }; + } } private void OnValueChanged()