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