コード例 #1
0
    // Start is called before the first frame update
    public void Init()
    {
        // Set the hand controller
        m_OVRControllerHelper.m_controller = m_OVRController;

        // Each hand comes with two detectors: a grip detector, and a tooltip detector
        // Their inclusion in the hand is totally optional. But a hand wouldn't really work if there wasn't at least one grab detection at some point...
        // A hand can still work without any detection for grip or tooltip... but that would seem odd, in a sense.
        if (m_gripDetector != null)
        {
            if (!m_gripDetector.shouldStartOnRun)
            {
                m_gripDetector.Init(true);
            }
            switch (m_OVRController)
            {
            case (OVRInput.Controller.LTouch):
                CustomEvents.current.onLeftGripDown += GripDown;
                CustomEvents.current.onLeftGripUp   += GripUp;
                break;

            case (OVRInput.Controller.RTouch):
                CustomEvents.current.onRightGripDown += GripDown;
                CustomEvents.current.onRightGripUp   += GripUp;
                break;
            }
        }
        if (m_tooltipDetector)
        {
            if (!m_tooltipDetector.shouldStartOnRun)
            {
                m_tooltipDetector.Init(true);
            }
        }

        // If a custom pointer is attached to this hand, we initialize it
        if (m_pointer != null)
        {
            m_pointer.Init(true, this);
            switch (m_OVRController)
            {
            case (OVRInput.Controller.LTouch):
                // CustomEvents.current.onLeftTriggerDown += TriggerDown;
                // CustomEvents.current.onLeftTriggerUp += TriggerUp;
                CustomEvents.current.onLeftTriggerDown += m_pointer.LineOn;
                CustomEvents.current.onLeftTriggerUp   += m_pointer.LineOff;
                break;

            case (OVRInput.Controller.RTouch):
                // CustomEvents.current.onRightTriggerDown += TriggerDown;
                // CustomEvents.current.onRightTriggerUp += TriggerUp;
                CustomEvents.current.onRightTriggerDown += m_pointer.LineOn;
                CustomEvents.current.onRightTriggerUp   += m_pointer.LineOff;
                break;
            }
        }
    }
コード例 #2
0
    /*
     * private enum grabAppearance {
     *  Never,
     *  Detecting,
     *  Holding,
     *  DetectAndHold,
     *  Always
     * }
     * [SerializeField]
     * [Tooltip("Setting the appearance of the grabbing grab_vol")]
     * private grabAppearance m_grabAppearance = grabAppearance.DetectAndHold;
     *
     * private enum debugType {
     *  None,
     *  Grab,
     *  Tooltip,
     *  Both
     * }
     * [SerializeField]
     * [Tooltip("Choose your debug type")]
     * private debugType m_debugType = debugType.None;
     */

    // Start is called before the first frame update
    void Start()
    {
        // Set the hand controller
        m_OVRControllerHelper.m_controller = m_OVRController;

        // Each hand comes with two detectors: a grip detector, and a tooltip detector
        // Their inclusion in the hand is totally optional. But a hand wouldn't really work if there wasn't at least one grab detection at some point...
        // A hand can still work without any detection for grip or tooltip... but that would seem odd, in a sense.
        if (m_gripDetector && !m_gripDetector.shouldStartOnRun)
        {
            m_gripDetector.Init(true);
        }
        if (m_tooltipDetector && !m_tooltipDetector.shouldStartOnRun)
        {
            m_tooltipDetector.Init(true);
        }

        // If a custom pointer is attached to this hand, we initialize it
        if (m_pointer != null)
        {
            m_pointer.Init(true);
        }

        // This script also checks key presses and button inputs for the controller
        // For reference, One = A/X, Two = B/Y
        // These values are updated in Update() rather than a coroutine to keep consistent with other scripts running in Update
        m_inputTimes.Add("index", -1f);
        m_inputTimes.Add("grip", -1f);
        m_inputTimes.Add("one", -1f);
        m_inputTimes.Add("two", -1f);
        m_inputTimes.Add("thumbDir", -1f);
        m_inputTimes.Add("thumbPress", -1f);

        m_inputDowns.Add("index", false);
        m_inputDowns.Add("grip", false);
        m_inputDowns.Add("one", false);
        m_inputDowns.Add("two", false);
        m_inputDowns.Add("thumbNorth", false);
        m_inputDowns.Add("thumbSouth", false);
        m_inputDowns.Add("thumbEast", false);
        m_inputDowns.Add("thumbWest", false);
        m_inputDowns.Add("thumbPress", false);

        m_thumbDirection = Vector2.zero;
        m_thumbAngle     = Vector2.zero;

        /*
         * if (debugToggle && m_gripTrans != m_controllerAnchor) {
         *  m_gripTrans.gameObject.SetActive(true);
         * }
         * m_OVRControllerHelper.m_controller = m_controller;
         * StartCoroutine(CheckGrip());
         */
    }