Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.UI;
- public class ScrollRectSnap : MonoBehaviour {
- ScrollRect scroll;
- bool LerpV;
- float targetV;
- void Start ()
- {
- scroll = gameObject.GetComponent<ScrollRect>();
- scroll.inertia = false;
- }
- void Update()
- {
- if(LerpV)
- {
- scroll.verticalNormalizedPosition = Mathf.Lerp( scroll.verticalNormalizedPosition, targetV, 10*scroll.elasticity*Time.deltaTime);
- if(Mathf.Approximately(scroll.verticalNormalizedPosition, targetV))
- LerpV = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement