Fix using unsigned integer properties in Visual Script editor
This commit is contained in:
@@ -109,8 +109,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
// Use int value editor with limit
|
||||
var element = layout.SignedIntegerValue();
|
||||
element.LongValue.SetLimits((LimitAttribute)limit);
|
||||
element.LongValue.MinValue = Mathf.Max(element.LongValue.MinValue, min);
|
||||
element.LongValue.MaxValue = Mathf.Min(element.LongValue.MaxValue, max);
|
||||
element.LongValue.SetLimits(Mathf.Max(element.LongValue.MinValue, min), Mathf.Min(element.LongValue.MaxValue, max));
|
||||
element.LongValue.ValueChanged += OnValueChanged;
|
||||
element.LongValue.SlidingEnd += ClearToken;
|
||||
_element = element;
|
||||
@@ -121,8 +120,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
{
|
||||
// Use int value editor
|
||||
var element = layout.SignedIntegerValue();
|
||||
element.LongValue.MinValue = Mathf.Max(element.LongValue.MinValue, min);
|
||||
element.LongValue.MaxValue = Mathf.Min(element.LongValue.MaxValue, max);
|
||||
element.LongValue.SetLimits(Mathf.Max(element.LongValue.MinValue, min), Mathf.Min(element.LongValue.MaxValue, max));
|
||||
element.LongValue.ValueChanged += OnValueChanged;
|
||||
element.LongValue.SlidingEnd += ClearToken;
|
||||
_element = element;
|
||||
@@ -278,8 +276,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
// Use int value editor with limit
|
||||
var element = layout.UnsignedIntegerValue();
|
||||
element.ULongValue.SetLimits((LimitAttribute)limit);
|
||||
element.ULongValue.MinValue = Mathf.Max(element.ULongValue.MinValue, min);
|
||||
element.ULongValue.MaxValue = Mathf.Min(element.ULongValue.MaxValue, max);
|
||||
element.ULongValue.SetLimits(Mathf.Max(element.ULongValue.MinValue, min), Mathf.Min(element.ULongValue.MaxValue, max));
|
||||
element.ULongValue.ValueChanged += OnValueChanged;
|
||||
element.ULongValue.SlidingEnd += ClearToken;
|
||||
_element = element;
|
||||
@@ -290,8 +287,7 @@ namespace FlaxEditor.CustomEditors.Editors
|
||||
{
|
||||
// Use int value editor
|
||||
var element = layout.UnsignedIntegerValue();
|
||||
element.ULongValue.MinValue = Mathf.Max(element.ULongValue.MinValue, min);
|
||||
element.ULongValue.MaxValue = Mathf.Min(element.ULongValue.MaxValue, max);
|
||||
element.ULongValue.SetLimits(Mathf.Max(element.ULongValue.MinValue, min), Mathf.Min(element.ULongValue.MaxValue, max));
|
||||
element.ULongValue.ValueChanged += OnValueChanged;
|
||||
element.ULongValue.SlidingEnd += ClearToken;
|
||||
_element = element;
|
||||
|
||||
@@ -93,6 +93,18 @@ namespace FlaxEditor.GUI.Input
|
||||
Value = Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the limits at once.
|
||||
/// </summary>
|
||||
/// <param name="min">The minimum value.</param>
|
||||
/// <param name="max">The minimum value.</param>
|
||||
public void SetLimits(long min, long max)
|
||||
{
|
||||
_min = Math.Min(min, max);
|
||||
_max = Math.Max(min, max);
|
||||
Value = Value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected sealed override void UpdateText()
|
||||
{
|
||||
|
||||
@@ -88,12 +88,24 @@ namespace FlaxEditor.GUI.Input
|
||||
/// <param name="limits">The limits.</param>
|
||||
public void SetLimits(LimitAttribute limits)
|
||||
{
|
||||
_min = limits.Min == int.MinValue ? ulong.MinValue : (ulong)limits.Min;
|
||||
_max = Math.Max(_min, limits.Max == int.MaxValue ? ulong.MaxValue : (ulong)limits.Max);
|
||||
_min = limits.Min < 0.0f ? 0 : (ulong)limits.Min;
|
||||
_max = Math.Max(_min, limits.Max == float.MaxValue ? ulong.MaxValue : (ulong)limits.Max);
|
||||
_slideSpeed = limits.SliderSpeed;
|
||||
Value = Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the limits at once.
|
||||
/// </summary>
|
||||
/// <param name="min">The minimum value.</param>
|
||||
/// <param name="max">The minimum value.</param>
|
||||
public void SetLimits(ulong min, ulong max)
|
||||
{
|
||||
_min = Math.Min(min, max);
|
||||
_max = Math.Max(min, max);
|
||||
Value = Value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected sealed override void UpdateText()
|
||||
{
|
||||
|
||||
@@ -332,7 +332,10 @@ namespace FlaxEditor.Surface
|
||||
/// <seealso cref="FlaxEditor.CustomEditors.CustomEditor" />
|
||||
public class ParametersEditor : CustomEditor
|
||||
{
|
||||
private static readonly Attribute[] DefaultAttributes = { new LimitAttribute(float.MinValue, float.MaxValue, 0.1f) };
|
||||
private static readonly Attribute[] DefaultAttributes =
|
||||
{
|
||||
//new LimitAttribute(float.MinValue, float.MaxValue, 0.1f),
|
||||
};
|
||||
|
||||
/// <inheritdoc />
|
||||
public override DisplayStyle Style => DisplayStyle.InlineIntoParent;
|
||||
|
||||
Reference in New Issue
Block a user