Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var lerping : boolean = false;
- var someRowHeight : float = 152.0;
- var scrollViewPosYPre : float = scrollViewPos.y;
- scrollViewPos = GUI.BeginScrollView (rectScrollBox, scrollViewPos, rectScrollView, false, true);
- for (var i:int=0; i < scrollItems.length; i++) {
- rectUnlocksItem.y = someRowHeight * i;
- GUI.Label (rectUnlocksItem, guiContentUnlocksItem, emptyGUIStyle);
- }
- GUI.EndScrollView();
- var scrollViewPosYPost : float = scrollViewPos.y;
- // not scrolling
- if( !lerping) {
- if (scrollViewPosYPre == scrollViewPosYPost) {
- // Debug.Log ("not scrolling...");
- if (scrollViewPosYPost % someRowHeight != 0) {
- Debug.Log (Time.time.ToString("f2") + ", " + gameObject.name + ": "+ "scrollViewPosYPost % someRowHeight: " + (scrollViewPosYPost % someRowHeight).ToString());
- lerping = true;
- myLerpFunction( scrollViewPosYPost, (int)(Mathf.Round(scrollPosition / (float)rowHeight) * rowHeight) );
- }
- }
- }
- function MyLerpFunction( startHeight : float, targetHeight : int )
- {
- var delta : float = targetHeight - startHeight;
- var index : float = 0.0;
- var rate : float = 1.0 / 0.5 //0.5 = time to lerp in seconds
- while( index < 1.0 )
- {
- index += Time.deltaTime * rate;
- currentHeight = startHeight + delta*index;
- yield;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement