예제 #1
0
    // Draws a 1D axis field.
    void DrawAxis1DField(ref Input1DAxis axis1D, ref Rect position)
    {
        // Prepare the labels and tooltips.
        GUIContent axisLabel   = new GUIContent(axis1D.Name, "The 1D axis used to simulate the XR controller's " + axis1D.Name + ".");
        GUIContent buttonLabel = new GUIContent(axis1D.Name + " Button", "The binary used to simulate the XR controller's " + axis1D.Name + " Button.");

        // Create the slider for the 1D axis value.
        float axisValue = EditorGUILayout.Slider(axisLabel, axis1D.Axis, 0.0f, 1.0f);

        position.y += VerticalSpace;

        // If the button is used.
        if (axis1D.ButtonIncluded)
        {
            // Create the checkbox for the button state.
            bool buttonValue = EditorGUILayout.Toggle(buttonLabel, axis1D.Button);
            position.y += VerticalSpace;

            // Update the button and axis.
            axis1D.ButtonAxis(buttonValue, axisValue);
        }
        // If the button is not included.
        else
        {
            // Update the axis.
            axis1D.Axis = axisValue;
        }
    }
    // Reset function for initializing the controller.
    void Reset()
    {
        // Reset the primary 2D axis.
        m_Primary2DAxis               = new Input2DAxis();
        m_Primary2DAxis.Name          = "Primary 2D Axis";
        m_Primary2DAxis.TouchIncluded = true;
        m_Primary2DAxis.ClickIncluded = true;

        // Reset the trigger.
        m_Trigger                = new Input1DAxis();
        m_Trigger.Name           = "Trigger";
        m_Trigger.ButtonIncluded = true;

        // Reset the grip.
        m_Grip                = new Input1DAxis();
        m_Grip.Name           = "Grip";
        m_Grip.ButtonIncluded = true;

        // Reset the primary button (i.e., sandwich button on the Vive).
        m_PrimaryButton       = new InputButton();
        m_PrimaryButton.Name  = "Primary";
        m_PrimaryButton.Touch = false;
    }