블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2731)
Unity3D (814)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (57)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (51)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
03-28 00:02

Momentum And Spring 


옵션을 주면.


양끝.


1~10번까지의 리스트가 있다면.


1번에서  리스트에 없는 0번위치까지 드래그가 되서 다시 1번으로 스프링되서 돌아오는 방식이다.(10번도 마찬가지 없는 11번으로 갔다가 다시 원래 10번으로 돌아옴)


Momentum 


옵션은.


그냥 정확히 끝에 1번이나 10번에서 멈춰서 양끝으로 더이상 드래그가 되질 않는 방식이다.




이 두개를 합쳐서 


Momentum And Spring 


옵션을 주고.


한쪽방향은 더이상 못움직이게.   한쪽방향은 스프링처럼 돌아오게 하려면.



UIScrollView - 클래스에서.


public bool m_BottomStop = false;
public bool m_TopStop = false;

변수 선언.

public void Drag () 의 

Vector3 constraint = mPanel.CalculateConstrainOffset(bounds.min, bounds.max);

if (constraint.magnitude > 1f)
{
    MoveAbsolute(offset * 0.5f);
mMomentum *= 0.5f;

}

이부분에.


if (constraint.magnitude > 1f)
{
MoveAbsolute(offset * 0.5f);
mMomentum *= 0.5f;

       //StopOption.
       if (m_BottomStop == true)
       {
             if (offset.y > 0)
               RestrictWithinBounds(true, canMoveHorizontally, canMoveVertically);
        }
        if (m_TopStop == true)
        {
              if (offset.y < 0)
                 RestrictWithinBounds(true, canMoveHorizontally, canMoveVertically);
         }
}

이렇게 적어주고

m_BottomStop 과 m_TopStop   에 True 값을 넣어줘서. 값을 셋팅해서 사용하면된다.


왼쪽 오른쪽도 만들고싶다면.

offset.x 를 활용하면 된다.



[출처] http://hanamoni.tistory.com/25

반응형
Posted by blueasa
, |