Exemplo n.º 1
0
    private void UpdateControllerState()
    {
        // Return early when the application isn't playing to ensure that the serialized
        // displayState is used to preview the controller visual instead of the default
        // GvrControllerInputDevice values.
#if UNITY_EDITOR
        if (!Application.isPlaying)
        {
            return;
        }
#endif

        if (ControllerInputDevice != null)
        {
            displayState.batteryLevel    = ControllerInputDevice.BatteryLevel;
            displayState.batteryCharging = ControllerInputDevice.IsCharging;

            displayState.clickButton =
                ControllerInputDevice.GetButton(GvrControllerButton.TouchPadButton);

            displayState.appButton  = ControllerInputDevice.GetButton(GvrControllerButton.App);
            displayState.homeButton = ControllerInputDevice.GetButton(GvrControllerButton.System);

            displayState.touching =
                ControllerInputDevice.GetButton(GvrControllerButton.TouchPadTouch);

            displayState.touchPos = ControllerInputDevice.TouchPos;
        }
    }
        protected override VisualAssets GetVisualAssets()
        {
            VisualAssets vizAssets = base.GetVisualAssets();

            int controllerVisualIndex = 0;

            if (ControllerInputDevice != null &&
                ControllerInputDevice.GetConfigurationType() ==
                GvrBetaControllerInput.Configuration.Is6DoF)
            {
                controllerVisualIndex = 1;
            }

            // Check that visualsAssets exists and that the visual index is within range.
            if (visualsAssets != null &&
                controllerVisualIndex < visualsAssets.Length)
            {
                vizAssets.material = visualsAssets[controllerVisualIndex].material;
                vizAssets.mesh     = visualsAssets[controllerVisualIndex].mesh;
            }
            return(vizAssets);
        }