Advertisement
Guest User

Untitled

a guest
Aug 29th, 2015
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1.  IEnumerator DragNach(float _target, float _time)
  2.     {
  3.         float _t = 0f;
  4.         while (_t<1)
  5.         {
  6.             _t += Time.deltaTime/_time;
  7.             sr.horizontalNormalizedPosition = Mathf.Lerp(sr.horizontalNormalizedPosition,_target,_t);
  8.             yield return null;
  9.         }
  10.         if (_target <= 0.1) transform.GetChild(2).SetAsFirstSibling(); else if (_target >= 0.9) transform.GetChild(0).SetAsLastSibling();
  11.         sr.horizontalNormalizedPosition = .5f;
  12.     }
  13.     public void OnEndDragging()
  14.     {
  15.      
  16.         StartCoroutine(DragNach(Mathf.Round(sr.horizontalNormalizedPosition * 2f) * .5f, .2f));
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement