Add safe check for LinkedLabel to prevent errors
This commit is contained in:
@@ -111,6 +111,8 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
SetLinkStyle();
|
||||
var textSize = FlaxEngine.GUI.Style.Current.FontMedium.MeasureText(LinkedLabel.Text.Value);
|
||||
_linkButton.LocalX += textSize.X + 10;
|
||||
if (LinkedLabel != null)
|
||||
{
|
||||
LinkedLabel.SetupContextMenu += (label, menu, editor) =>
|
||||
{
|
||||
menu.AddSeparator();
|
||||
@@ -119,6 +121,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
else
|
||||
menu.AddButton("Link", ToggleLink).LinkTooltip("Links scale components for uniform scaling");
|
||||
};
|
||||
}
|
||||
|
||||
// Override colors
|
||||
var back = FlaxEngine.GUI.Style.Current.TextBoxBackground;
|
||||
|
||||
@@ -34,6 +34,8 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
if (valueCategory != Utils.ValueCategory.None)
|
||||
{
|
||||
doubleValue.SetCategory(valueCategory);
|
||||
if (LinkedLabel != null)
|
||||
{
|
||||
LinkedLabel.SetupContextMenu += (label, menu, editor) =>
|
||||
{
|
||||
menu.AddSeparator();
|
||||
@@ -44,6 +46,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnValueChanged()
|
||||
{
|
||||
|
||||
@@ -53,6 +53,8 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
if (valueCategory != Utils.ValueCategory.None)
|
||||
{
|
||||
floatValue.SetCategory(valueCategory);
|
||||
if (LinkedLabel != null)
|
||||
{
|
||||
LinkedLabel.SetupContextMenu += (label, menu, editor) =>
|
||||
{
|
||||
menu.AddSeparator();
|
||||
@@ -63,6 +65,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnValueChanged()
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
/// <inheritdoc />
|
||||
public override void Initialize(LayoutElementsContainer layout)
|
||||
{
|
||||
if (LinkedLabel != null)
|
||||
LinkedLabel.SetupContextMenu += OnSetupContextMenu;
|
||||
var comboBoxElement = layout.ComboBox();
|
||||
_comboBox = comboBoxElement.ComboBox;
|
||||
|
||||
@@ -59,6 +59,8 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
ZElement.ValueBox.ValueChanged += OnValueChanged;
|
||||
ZElement.ValueBox.SlidingEnd += ClearToken;
|
||||
|
||||
if (LinkedLabel != null)
|
||||
{
|
||||
LinkedLabel.SetupContextMenu += (label, menu, editor) =>
|
||||
{
|
||||
menu.AddSeparator();
|
||||
@@ -66,6 +68,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
menu.AddButton("Copy Euler", () => { Clipboard.Text = JsonSerializer.Serialize(value); }).TooltipText = "Copy the Euler Angles in Degrees";
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private void OnValueChanged()
|
||||
{
|
||||
|
||||
@@ -96,6 +96,9 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
ZElement.SetCategory(category);
|
||||
ZElement.ValueBox.ValueChanged += OnZValueChanged;
|
||||
ZElement.ValueBox.SlidingEnd += ClearToken;
|
||||
|
||||
if (LinkedLabel != null)
|
||||
{
|
||||
LinkedLabel.SetupContextMenu += (label, menu, editor) =>
|
||||
{
|
||||
menu.AddSeparator();
|
||||
@@ -109,6 +112,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
mb.Checked = XElement.ValueBox.Category != Utils.ValueCategory.None;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private void OnXValueChanged()
|
||||
{
|
||||
@@ -294,6 +298,9 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
ZElement.SetCategory(category);
|
||||
ZElement.ValueBox.ValueChanged += OnValueChanged;
|
||||
ZElement.ValueBox.SlidingEnd += ClearToken;
|
||||
|
||||
if (LinkedLabel != null)
|
||||
{
|
||||
LinkedLabel.SetupContextMenu += (label, menu, editor) =>
|
||||
{
|
||||
menu.AddSeparator();
|
||||
@@ -307,6 +314,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
mb.Checked = XElement.ValueBox.Category != Utils.ValueCategory.None;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private void OnValueChanged()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user