private void OnPlacementScaleAction(InputAction.CallbackContext context)
        {
            if (m_CachedPlacementGesturesEnabled != true)
            {
                return;
            }

            PinchGestureInteraction interaction = context.interaction as PinchGestureInteraction;

            if (interaction?.currentGesture != null)
            {
                PinchGesture pinchGesture = interaction?.currentGesture as PinchGesture;
                var          ratio        = m_InitialScaleSize / pinchGesture.gap; // inverted because scale size is 1/N
                var          newScale     = GetNearestEnumValue((float)m_CachedModelScale * ratio);
                UIStateManager.current.Dispatcher.Dispatch(Payload <ActionTypes> .From(ActionTypes.SetModelScale, newScale));
            }
        }
        void OnPlacementScaleAction(InputAction.CallbackContext context)
        {
            if (!m_ARScaleEnabledSelector.GetValue())
            {
                return;
            }

            PinchGestureInteraction interaction = context.interaction as PinchGestureInteraction;

            if (interaction?.currentGesture != null)
            {
                PinchGesture pinchGesture = interaction?.currentGesture as PinchGesture;
                var          ratio        = m_InitialScaleSize / pinchGesture.gap; // inverted because scale size is 1/N
                var          newScale     = GetNearestEnumValue(m_InitialModelScale * ratio);
                Dispatcher.Dispatch(SetModelScaleAction.From(newScale));
            }
        }
示例#3
0
        void OnZoomGestureStarted(InputAction.CallbackContext context)
        {
            if (m_PanGestureInProgress || m_ZoomGestureInProgress)
            {
                return;
            }

            PinchGestureInteraction interaction = context.interaction as PinchGestureInteraction;

            if (interaction?.currentGesture != null)
            {
                PinchGesture pinchGesture = interaction?.currentGesture as PinchGesture;
                m_ZoomGestureInProgress      = true;
                m_GestureCameraStartPosition = m_Camera.GetDistanceFromLookAt();
                pinchGesture.onFinished     += OnZoomGestureFinished;
            }
        }
        private void OnPlacementScaleActionStarted(InputAction.CallbackContext context)
        {
            if (m_CachedPlacementGesturesEnabled != true)
            {
                return;
            }

            PinchGestureInteraction interaction = context.interaction as PinchGestureInteraction;

            if (interaction?.currentGesture != null)
            {
                PinchGesture pinchGesture = interaction?.currentGesture as PinchGesture;
                m_InitialScaleSize       = pinchGesture.gap;
                m_CachedModelScale       = UIStateManager.current.stateData.modelScale;
                m_ScaleActionInProgress  = true;
                pinchGesture.onFinished += OnPlacementScaleActionFinished;
            }
        }
        void OnPlacementScaleActionStarted(InputAction.CallbackContext context)
        {
            if (!m_ARScaleEnabledSelector.GetValue())
            {
                return;
            }

            PinchGestureInteraction interaction = context.interaction as PinchGestureInteraction;

            if (interaction?.currentGesture != null)
            {
                PinchGesture pinchGesture = interaction?.currentGesture as PinchGesture;
                m_InitialScaleSize       = pinchGesture.gap;
                m_InitialModelScale      = (float)m_ModelScaleSelector.GetValue();
                m_ScaleActionInProgress  = true;
                pinchGesture.onFinished += OnPlacementScaleActionFinished;
            }
        }