@ArenMook:
I test code
if (contentPadding < 0.001f) contentPadding = 0f;
else if (contentPadding > 0.999f) contentPadding = 1f;
sb.barSize = 1f - contentPadding;
Incorrect behavior is present. (size was <1)
рow to check the condition (else if (contentPadding > 0.999f) contentPadding = 1f;)?
In my version, I changed the value of the constant 0.01 to 0.1. And it works perfectly.
protected void UpdateScrollbars(UIProgressBar slider, float contentMin, float contentMax, float contentSize, float viewSize, bool inverted)
{
if (slider == null)
return;
mIgnoreCallbacks = true;
if (viewSize < contentSize)
{
contentMin = Mathf.Clamp01(contentMin / contentSize);
contentMax = Mathf.Clamp01(contentMax / contentSize);
var contentPadding = contentMin + contentMax;
slider.value = inverted ? ((contentPadding > 0.001f) ? 1f - contentMin / contentPadding : 0f) :
((contentPadding > 0.001f) ? contentMin / contentPadding : 1f);
var sb = slider as UIScrollBar;
if (sb != null) sb.barSize = 1f - contentPadding;
}
else
{
contentMin = Mathf.Clamp01(-contentMin / contentSize);
contentMax = Mathf.Clamp01(-contentMax / contentSize);
var contentPadding = contentMin + contentMax;
slider.value = inverted ? ((contentPadding > 0.001f) ? 1f - contentMin / contentPadding : 0f) :
((contentPadding > 0.001f) ? contentMin / contentPadding : 1f);
if (contentSize > 0)
{
contentMin = Mathf.Clamp01(contentMin / contentSize);
contentMax = Mathf.Clamp01(contentMax / contentSize);
contentPadding = contentMin + contentMax;
}
var sb = slider as UIScrollBar;
if (sb != null)
{
contentPadding = (contentPadding < 0.1f) ? 0 : 1;
sb.barSize = 1f - contentPadding;
}
}
mIgnoreCallbacks = false;
}