public class TouchManager : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
{
public void OnBeginDrag(PointerEventData _eventData)
{
transform.position = _eventData.position;
}
public void OnDrag(PointerEventData _eventData)
{
transform.position = _eventData.position;
}
public void OnEndDrag(PointerEventData _eventData)
{
transform.position = _eventData.position;
}
}
- 이벤트 핸들러를 붙여서 스크립트상에서 구현하는 것 (인스펙터에서도 붙일 수 있슴)
- using UnityEngine.EventSystems;
- UI Object에 부착
+) 드래그로 회전
void TouchRotation(Touch touch)
{
if (touch.phase == TouchPhase.Began)
{
initTouch = touch;
}
else if (touch.phase == TouchPhase.Moved)
{
float deltaX = initTouch.position.x - touch.position.x;
rotY += deltaX * Time.deltaTime * rotSpeed * dir;
Target.eulerAngles = new Vector3(rotX, rotY, 0f);
}
else if (touch.phase == TouchPhase.Ended)
{
initTouch = new Touch();
}
}
'NOTE > SaveSource' 카테고리의 다른 글
| [Source Save] TouchCameraMove.cs (0) | 2016.10.31 |
|---|---|
| [Source Save] InputTouchManager.cs (0) | 2016.10.27 |
| [SaveSource] Touch Pinch Zoom (0) | 2016.10.14 |
| [SaveSource] Player Cam & Input.Axis (0) | 2016.10.07 |
| [SaveSource] GyroScope Camera (0) | 2016.10.06 |