示例#1
0
    /// <summary>
    /// Starts dragging the object.
    /// </summary>
    public void StartRotating()
    {
        if (!IsRotatingEnabled)
        {
            return;
        }

        if (isRotating)
        {
            return;
        }

        // Add self as a modal input handler, to get all inputs during the manipulation
        InputManager.Instance.PushModalInputHandler(gameObject);

        isRotating = true;

        Vector3 handPosition;

        currentInputSource.TryGetPosition(currentInputSourceId, out handPosition);

        // Store the initial offset between the hand and the object, so that we can consider it when dragging
        startRotation     = HostTransform.rotation;
        startHandPosition = handPosition;
        startDir          = Vector3.Normalize(HostTransform.position - handPosition);
        StartedRotating.RaiseEvent();
    }
示例#2
0
        /// <summary>
        /// Starts rotating the object with the given input source.
        /// </summary>
        public void StartRotating(IInputSource inputSource, uint inputSourceId)
        {
            if (IsRotating)
            {
                return;
            }

            if (inputSource == null || !inputSource.SupportsInputInfo(inputSourceId, SupportedInputInfo.Position))
            {
                Debug.Log("The input source must provide positional data for Rotatable to be usable.");
                return;
            }

            currentInputSource   = inputSource;
            currentInputSourceId = inputSourceId;

            currentInputSource.TryGetPosition(currentInputSourceId, out prevHandPosition);

            // Add self as a modal input handler, to get all inputs during the manipulation.
            InputManager.Instance.PushModalInputHandler(gameObject);

            IsRotating = true;
            StartedRotating.RaiseEvent();
        }