Exemplo n.º 1
0
        private XRPointEventData GetFingerPointerEventData(FingerPointer finger, out bool pressed, out bool released)
        {
            XRPointEventData pointerData;
            var created = GetFingerPointerData(finger.fingerId, out pointerData, true);

            pointerData.Reset();

            pointerData.origin        = finger.origin;
            pointerData.direction     = finger.direction;
            pointerData.hitDistance   = finger.raycastDistance;
            pointerData.button        = PointerEventData.InputButton.Left;
            pointerData.raycastCamera = finger.raycastCamera;
            pointerData.position      = new Vector2(finger.raycastCamera.pixelWidth * 0.5f, finger.raycastCamera.pixelHeight * 0.5f);

            pointerData.useFingerRaycast = true;
            eventSystem.RaycastAll(pointerData, m_RaycastResultCache);
            var raycast = FindFirstRaycast(m_RaycastResultCache);

            pointerData.pointerCurrentRaycast = raycast;
            m_RaycastResultCache.Clear();

            //更新手指状态
            finger.UpdateStateFormRaycast(ref raycast);
            pressed           = created || (finger.phase == TouchPhase.Began);
            released          = (finger.phase == TouchPhase.Canceled) || (finger.phase == TouchPhase.Ended);
            pointerData.force = finger.force;

            if (finger.phase == TouchPhase.Canceled)
            {
                pointerData.pointerCurrentRaycast = new RaycastResult();
            }
            else
            {
                if (created)
                {
                    pointerData.hitPoint = raycast.worldPosition;
                }
                if (pressed)
                {
                    pointerData.delta = Vector2.zero;
                }
                else
                {
                    pointerData.delta = finger.delta;
                }
                pointerData.hitNormal = finger.hitNormal;
                pointerData.hitPoint  = finger.hitPoint;
            }

            return(pointerData);
        }
Exemplo n.º 2
0
 internal static void Remove(FingerPointer finger)
 {
     GetFingers()?.Remove(finger);
 }
Exemplo n.º 3
0
 internal static void Regist(FingerPointer finger)
 {
     GetFingers().Add(finger);
 }