Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4.  
  5. public class ScrollRectSnap : MonoBehaviour {
  6.  
  7. ScrollRect scroll;
  8.  
  9. bool LerpV;
  10. float targetV;
  11.  
  12. void Start ()
  13. {
  14. scroll = gameObject.GetComponent<ScrollRect>();
  15. scroll.inertia = false;
  16. }
  17.  
  18. void Update()
  19. {
  20. if(LerpV)
  21. {
  22. scroll.verticalNormalizedPosition = Mathf.Lerp( scroll.verticalNormalizedPosition, targetV, 10*scroll.elasticity*Time.deltaTime);
  23.  
  24. if(Mathf.Approximately(scroll.verticalNormalizedPosition, targetV))
  25. LerpV = false;
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement