Fix initial lerp jumping for Progress bar on first update.
This commit is contained in:
@@ -169,6 +169,9 @@ namespace FlaxEngine.GUI
|
|||||||
[EditorDisplay("Bar Style"), EditorOrder(2012), Tooltip("The brush used for progress bar drawing.")]
|
[EditorDisplay("Bar Style"), EditorOrder(2012), Tooltip("The brush used for progress bar drawing.")]
|
||||||
public IBrush BarBrush { get; set; }
|
public IBrush BarBrush { get; set; }
|
||||||
|
|
||||||
|
// Used to remove initial lerp from the value on play.
|
||||||
|
private bool _firstUpdate = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ProgressBar"/> class.
|
/// Initializes a new instance of the <see cref="ProgressBar"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -202,7 +205,7 @@ namespace FlaxEngine.GUI
|
|||||||
{
|
{
|
||||||
// Lerp or not if running slow
|
// Lerp or not if running slow
|
||||||
bool isDeltaSlow = deltaTime > (1 / 20.0f);
|
bool isDeltaSlow = deltaTime > (1 / 20.0f);
|
||||||
if (!isDeltaSlow && UseSmoothing)
|
if (!isDeltaSlow && UseSmoothing && !_firstUpdate)
|
||||||
value = Mathf.Lerp(_current, _value, Mathf.Saturate(deltaTime * 5.0f * SmoothingScale));
|
value = Mathf.Lerp(_current, _value, Mathf.Saturate(deltaTime * 5.0f * SmoothingScale));
|
||||||
_current = value;
|
_current = value;
|
||||||
}
|
}
|
||||||
@@ -213,6 +216,9 @@ namespace FlaxEngine.GUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
base.Update(deltaTime);
|
base.Update(deltaTime);
|
||||||
|
|
||||||
|
if (_firstUpdate)
|
||||||
|
_firstUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
Reference in New Issue
Block a user