마우스 포인터를 활용, 해당 오브젝트를 선택한 상태에서 움직일 수 있게 한다. 마우스 버튼이 눌리고 있는 동안에, 매 프레임마다 호출됩니다. Ref. Unity - 스크립팅 API: MonoBehaviour.OnMouseDrag() Success! Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. 닫기 docs.unity3d.com Suggest a change Success!Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable. Close Submission failedFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation. Close Your name Your email Suggestion* Cancel Switch to Manual DescriptionOnMouseDrag is called when the user has clicked on a Collider and is still holding down the mouse. OnMouseDrag is called every frame while the mouse is down. This function is not called on objects that belong to Ignore Raycast layer. This function is called on Colliders marked as Trigger if and only if Physics.queriesHitTriggers is true. OnMouseDrag can be a co-routine, simply use the yield statement in the function. This event is sent to all scripts attached to the Collider. NGUI 무료버전2.7.0 (2014.7. 21 기준)에서는 Scroll View 컴포넌트가 없었다. (내가 못찾은것일지도...) 1. UI Root 하위의 Panel 을 선택 2. 이름을 mainMenu로 변경 3. Component - NGUI - interaction - Scroll view 를 선택 ======================================================================== Movement : 패널을 스크롤 할 수 있는 방향을 지정한다. Drag Effect : 패널을 드래그할 때 자연스러운 멈춤효과를 재현하기 위한 효과선택 Scroll wheel Factor : 마우스 스크롤 휠로 패널의 Y축 상에서 드래그하려고 할 때, 이 곳에 0이상으 ㅣ값을 입력한다. Momentum Amount : 패널을 드래그해서 놓았을 때 적용할 탄련을 의미 Reset Position : 코드에 의해 스크롤 뷰의 위치를 초기화 할때 스크롤 뷰가 되돌아올 위치를 지정한다. Restrict within Panel : 스크롤 뷰의 내용이 스크롤 뷰 영역을 벗어나지 않게 제한한다. Cancel Drag if fits : 스크롤 뷰의 내용이 스크롤 뷰 영역을 벗어나지 않게 제한한다. Smooth Drag Start : 드래그를 시작할 때 패널이 건너 뛰는 현상을 피한다. IOS Drag Emulation 클리핑 영역을 넘어갈 때 드래그 되는 속력이 감소한다. Show Condition : 언제 스크롤바를 보여줄 것인지 조건을 선택한다. ============================================================================== 드래그패널 UIPanel 을 드래그할 수 있는 패널로 만들기 위해 UI Scroll view 컴포넌트를 추가했다. 이제 MainMenu를 드래그 할 수 있는 내용을 담은 게임오브젝트로 만들어야한다. 사용자가 패널을 클릭해서 드래그하려면 BoxCollider 컴포넌트가 필요하다. 1. MainMeunu 게임오브젝트를 선택한다. 1.UIPanal의 Clipping 파라미터에서 Alpha Clip을 선택한다. 2. Clipping 에 있는 size 필드에 1920, 1080dmf dlqfurgksek. 3. UIScroll view에서 IOS Drag Emulation 옵션을 해제한다. 2. Component - NGUI - inteaction - Drag Scroll view를 선택해서 MainMenu게임오브젝트에 UI Drag Scroll 컴포넌트를 추가한다. 3. NGUI - Attach - Collider 를 선택해서 Box Collider 를 추가한다. 1. is Trigger 옵션이 체크되어있는지 확인한다, 충돌거리까지는 필요없다. UICamera의 레이캐스트를 감지하기 위한 트래거면 충분하다. 2. center 에는 0, 395, 0 을 입력한다. 3. size 에는 1300, 62, 1 을 입력한다. 오직 X축으로만 창을 드래그 할 수 있다. 메인 메뉴의 창을 자유롭게 드래그 할수 있도록 수정해본다. 1. Main<enu 게임오브젝트를 선택한다. 2. UIScroll view컴포넌트와 MoveMent를 Unrestricted로 바꾼다. 메뉴창을 화면밖으로 드래그한다음 마우스 번튼을 놓으면 창이 다시화면안으로 들어온다. Restrict withinanel 옵션에 의한 것이다.
|