Unity/Unity 리서치

Mobile Pinch Zoom

lipnus 2021. 6. 9. 18:10
반응형

 

 

Getting Mobile Input - Unity Learn

Modern mobile devices have screens that can receive accurate multitouch inputs from the user and from multiple device sensors. In this tutorial you will learn how to get inputs from the touchscreen and accelerometer, and build a basic "pinch to zoom" mecha

learn.unity.com

 

 

핀치줌 변화량 리턴하는 매소드

private float getPichZoomValue()
        {
            float deltaMagnitudeDiff = 0f; 

            if (Input.touchCount == 2)
            {
                Touch touchZero = Input.GetTouch(0);
                Touch touchOne = Input.GetTouch(1);

                Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition;
                Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition;

                float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude;
                float touchDeltaMag = (touchZero.position - touchOne.position).magnitude;

                deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag;
            }
            return deltaMagnitudeDiff;
        }

 

반응형

'Unity > Unity 리서치' 카테고리의 다른 글

[RTS Engine] Camera관련 코드  (0) 2021.06.10
Touch.deltaposition  (0) 2021.06.10
Mouse DoubleClick  (0) 2021.06.08
모바일 더블 터치(Mobile Double Touch) 구현  (0) 2021.06.06
Mobile에서 터치 드래그 구현  (0) 2021.06.06