Add safe check for LinkedLabel to prevent errors
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
/// <inheritdoc />
|
||||
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<string>();
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user