Reputation: 57
I am using Mathf.Clamp to clamp 2 values for the vertical scroll view. Unfortunately there is a noticeable jitter when I try to scroll more than required value. The two values I clamp is between 0.5 and 1. But I notice that it goes below 0.5 and above 1 when I scroll (minimum value it goes is between 4.6-4.9 and max is 1.1-1.3). Could these values be fixed so that there won't be a jitter?
public ScrollRect scrollRect;
void Update () {
Debug.Log(scrollRect.verticalScrollbar.value);
scrollRect.verticalScrollbar.value = Mathf.Clamp(scrollRect.verticalScrollbar.value, 0.5f, 1);
}
Upvotes: 1
Views: 75
Reputation: 36
I guess your update is being executed before the ScrollRect update, so your Clamp could be overwritten by the ScrollRect's update (I'm not sure if this explanation is clear). If this is the case, using LateUpdate instead of Update would fix your problem. https://docs.unity3d.com/ScriptReference/MonoBehaviour.LateUpdate.html
Upvotes: 1