Пример #1
0
        protected override void OnUpdatePoses()
        {
            switch (_node)
            {
            case XRNode.LeftHand:
                _controller = GvrControllerInput.GetDevice(GvrControllerHand.Left);
                break;

            case XRNode.RightHand:
                _controller = GvrControllerInput.GetDevice(GvrControllerHand.Right);
                break;
            }

            if (_controller != null)
            {
                nodePosition = _controller.Position;
                nodeRotation = _controller.Orientation;
            }

            if (!_overridePosition)
            {
                transform.localPosition = nodePosition;
            }
            else
            {
                transform.position = _positionTarget.position;
            }

            transform.localRotation = nodeRotation;
        }
Пример #2
0
 // Start is called before the first frame update
 void Start()
 {
     controller = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);
     hudVideo.SetActive(true);
     followVideo.SetActive(false);
     podium.SetActive(false);
 }
    void Update()
    {
        if (VRDevice.OculusGo)         //OculusGo
        {
            OVRInput.Update();
            foreach (VRAction action in actions)
            {
                if (OVRInput.Get(action.oculusGoInput))
                {
                    action.onInput.Invoke();
                }
            }
        }
        else if (VRDevice.MirageSolo)           //MirageSolo
        {
            foreach (VRAction action in actions)
            {
                if (GvrControllerInput.GetDevice(GvrControllerHand.Dominant).GetButton(action.mirageInput))
                {
                    action.onInput.Invoke();
                }
            }
        }
        else if (VRDevice.GearVR)           //GearVR (no support for actions)

        {
        }
    }
Пример #4
0
        // Runtime switching enabled only in-editor.
        private void Update()
        {
            UpdateStatusMessage();

            // Scan all devices' buttons for button down, and switch the singleton pointer
            // to the controller the user last clicked.
            int newPointer = activeControllerPointer;

            if (controllerPointers.Length > 1 && controllerPointers[1] != null)
            {
                GvrTrackedController trackedController1 =
                    controllerPointers[1].GetComponent <GvrTrackedController>();
                foreach (var hand in ALL_HANDS)
                {
                    GvrControllerInputDevice device = GvrControllerInput.GetDevice(hand);
                    if (device.GetButtonDown(POINTER_BUTTON_MASK))
                    {
                        // Match the button to our own controllerPointers list.
                        if (device == trackedController1.ControllerInputDevice)
                        {
                            newPointer = 1;
                        }
                        else
                        {
                            newPointer = 0;
                        }
                        break;
                    }
                }
            }

            if (newPointer != activeControllerPointer)
            {
                activeControllerPointer = newPointer;
                SetVRInputMechanism();
            }

#if !RUNNING_ON_ANDROID_DEVICE
            UpdateEmulatedPlatformIfPlayerSettingsChanged();
            if ((isDaydream && gvrEmulatedPlatformType == EmulatedPlatformType.Daydream) ||
                (!isDaydream && gvrEmulatedPlatformType == EmulatedPlatformType.Cardboard))
            {
                return;
            }

            isDaydream = (gvrEmulatedPlatformType == EmulatedPlatformType.Daydream);
            SetVRInputMechanism();
#else
            // Running on an Android device.
            // Viewer type switched at runtime.
            if (!IsDeviceDaydreamReady() || viewerPlatform == GvrSettings.ViewerPlatform)
            {
                return;
            }

            isDaydream     = GvrSettings.ViewerPlatform == GvrSettings.ViewerPlatformType.Daydream;
            viewerPlatform = GvrSettings.ViewerPlatform;
            SetVRInputMechanism();
#endif  // !RUNNING_ON_ANDROID_DEVICE
        }
Пример #5
0
    private void SetupControllerInputDevice()
    {
        GvrControllerInputDevice newDevice = GvrControllerInput.GetDevice(controllerHand);

        if (controllerInputDevice == newDevice)
        {
            return;
        }
        if (controllerInputDevice != null)
        {
            controllerInputDevice.OnStateChanged -= OnControllerStateChanged;
            controllerInputDevice = null;
        }

        controllerInputDevice = newDevice;
        if (controllerInputDevice != null)
        {
            controllerInputDevice.OnStateChanged += OnControllerStateChanged;
            OnControllerStateChanged(controllerInputDevice.State, controllerInputDevice.State);
        }
        else
        {
            OnControllerStateChanged(GvrConnectionState.Disconnected, GvrConnectionState.Disconnected);
        }
        PropagateControllerInputDevice();
    }
Пример #6
0
    public int siteLayer   = 10; // This should match the layer number sites are in

    // Use this for initialization
    void Start()
    {
        _dominantController = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);
        //_previousOrientation = _dominantController.Orientation * Vector3.forward;
        _previousTouch = _dominantController.TouchPos;
        _translate     = new Vector3();
        _initTransform = this.transform.position;
    }
Пример #7
0
 private void Start()
 {
     controller = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);
     if (!anchored)
     {
         AttachToCamera();
     }
 }
Пример #8
0
 // Start is called before the first frame update
 void Start()
 {
     controller = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);
     menu.SetActive(false);
     countdownBox.SetActive(true);
     timer          = 0.0f;
     actionComplete = false;
     menuActive     = false;
 }
Пример #9
0
    // Update is called once per frame
    void Update()
    {
        GvrPointerInputModule.Pointer = GvrLaserPointer;

        var device = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);

        Teleport(device);
        Rotate(device);
    }
Пример #10
0
 void Update()
 {
     if (VRDevice.OculusGo)         //On OculusGo, use the controller's trigger to recalibrate
     {
         OVRInput.Update();
         if (OVRInput.Get(oculusGoRecenterButton))
         {
             Recenter();
         }
         if (OVRInput.Get(oculusGoQuitButton))
         {
             Application.Quit();
         }
     }
     else if (VRDevice.MirageSolo)           //On Mirage Solo, use the controller's click button
     {
         bool overrideTouch = false;
         bool overrideQuit  = false;
         GvrControllerInputDevice device = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);
         if (device == null)
         {
             device = GvrControllerInput.GetDevice(GvrControllerHand.NonDominant);
             if (device == null)
             {
                 Haze.Logger.LogError("Daydream Input API Status: " + GvrControllerInput.ApiStatus);
                 Haze.Logger.LogError("ErrorDetails: " + GvrControllerInput.ErrorDetails);
             }
         }
         if ((device != null && device.GetButton(mirageRecenterButton)) || overrideTouch)
         {
             Recenter();
         }
         if ((device != null && device.GetButton(mirageQuitButton)) || overrideQuit)
         {
             Application.Quit();
         }
     }
     else if (VRDevice.GearVR)         //On GearVR, double-tap to recalibrate
     {
         if (firstTap > 0)             //we've tapped a first time!
         {
             if (Input.GetMouseButtonDown(0))
             {
                 //that's it, double-tapped.
                 Recenter();
                 firstTap = 0;
             }
             firstTap -= Time.deltaTime;
         }
         else if (Input.GetMouseButtonUp(0))
         {
             firstTap = 0.3f;                //you have .3 seconds to tap once more for double tap!
         }
     }
 }
 private void Update()
 {
     foreach (var hand in Gvr.Internal.ControllerUtils.AllHands)
     {
         GvrControllerInputDevice device = GvrControllerInput.GetDevice(hand);
         if (device.GetButtonUp(GvrControllerButton.App))
         {
             CycleSeeThroughModes();
         }
     }
 }
Пример #12
0
        /// Returns true the frame after the user stops pressing down any of buttons specified
        /// in `buttons` on any controller.
        public static bool AnyButtonUp(GvrControllerButton buttons)
        {
            bool ret = false;

            foreach (var hand in AllHands)
            {
                GvrControllerInputDevice device = GvrControllerInput.GetDevice(hand);
                ret |= device.GetButtonUp(buttons);
            }
            return(ret);
        }
Пример #13
0
 // Start is called before the first frame update
 void Start()
 {
     videoPlay  = true;
     audioPlay  = false;
     currAudio  = Resources.Load <AudioClip>("Audio/Section1/" + audioFiles[0]);
     controller = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);
     Reset();
     overlay.SetActive(false);
     visionBlocker.SetActive(false);
     playVideo.videoPlayer.enabled = false;
     playVideo.videoCanvas.SetActive(false);
 }
Пример #14
0
    // Update is called once per frame
    async void Update()
    {
        GvrPointerInputModule.Pointer = GvrLaserPointer;

        transform.GetChild(0).localScale = Vector3.zero;

        var device = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);

        var otherCardSelected = BoardManager.AnyCardsSelected();

        if (Selected ||
            (GvrLaserPointer.CurrentRaycastResult.gameObject != null &&
             GvrLaserPointer.CurrentRaycastResult.gameObject == gameObject &&
             !otherCardSelected))
        {
            transform.GetChild(0).localScale = Vector3.one;

            if (device.GetButtonUp(GvrControllerButton.TouchPadButton))
            {
                Selected = true;
            }
        }

        if (Selected)
        {
            var deviceWorldPosition = Player.transform.TransformPoint(device.Position);

            if (!wasSelected)
            {
                distance = Vector3.Distance(deviceWorldPosition, transform.position);

                wasSelected = true;

                GetComponent <Rigidbody>().detectCollisions = false;
            }

            transform.position = GvrLaserPointer.GetPointAlongPointer(distance) + new Vector3(0, -0.5f, 0);

            distance = Mathf.Lerp(distance, 3.0f, Time.deltaTime * 2);

            if (GvrLaserPointer.CurrentRaycastResult.gameObject != null &&
                GvrLaserPointer.CurrentRaycastResult.gameObject.tag == SWIM_LANE_TAG &&
                device.GetButtonUp(GvrControllerButton.TouchPadButton))
            {
                await CardClient.MoveCardAsync(cardModel, GvrLaserPointer.CurrentRaycastResult.gameObject.GetComponent <SwimLane>().SwimLaneModel);
            }
        }
        else if (!otherCardSelected)
        {
            wasSelected = false;
        }
    }
Пример #15
0
    void Update()
    {
        bool connected = false;

        foreach (var hand in Gvr.Internal.ControllerUtils.AllHands)
        {
            GvrControllerInputDevice device = GvrControllerInput.GetDevice(hand);
            if (device.State == GvrConnectionState.Connected)
            {
                connected = true;
                break;
            }
        }

        if (!connected)
        {
            return;
        }

// Daydream is loaded only on deivce, not in editor.
#if UNITY_ANDROID && !UNITY_EDITOR
        if (XRSettings.loadedDeviceName != GvrSettings.VR_SDK_DAYDREAM)
        {
            return;
        }
#endif

        if (GvrControllerInput.Recentered)
        {
            ApplyYawCorrection();
            return;
        }

#if UNITY_EDITOR
        // Compatibility for Instant Preview.
        if (Gvr.Internal.InstantPreview.Instance != null &&
            Gvr.Internal.InstantPreview.Instance.enabled &&
            Gvr.Internal.ControllerUtils.AnyButton(GvrControllerButton.System))
        {
            return;
        }
#else  // !UNITY_EDITOR
        if (Gvr.Internal.ControllerUtils.AnyButton(GvrControllerButton.System))
        {
            return;
        }
#endif  // UNITY_EDITOR

        yawCorrection = GetYawCorrection();
    }
Пример #16
0
        public override void OnActivated()
        {
            EnsureDeviceStateLength(3);

            if (Object.FindObjectOfType <GvrHeadset>() == null)
            {
                VRModule.Instance.gameObject.AddComponent <GvrHeadset>();
            }

            if (Object.FindObjectOfType <GvrControllerInput>() == null)
            {
                VRModule.Instance.gameObject.AddComponent <GvrControllerInput>();
            }

            m_rightDevice = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);
            m_leftDevice  = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);

            var armModels = VRModule.Instance.GetComponents <GvrArmModel>();

            if (armModels != null && armModels.Length >= 1)
            {
                m_rightArm = armModels[0];
            }
            else
            {
                m_rightArm = VRModule.Instance.GetComponent <GvrArmModel>();

                if (m_rightArm == null)
                {
                    m_rightArm = VRModule.Instance.gameObject.AddComponent <GvrArmModel>();
                }
            }
            m_rightArm.ControllerInputDevice = m_rightDevice;

            if (armModels != null && armModels.Length >= 2)
            {
                m_leftArm = armModels[1];
            }
            else
            {
                m_leftArm = VRModule.Instance.GetComponent <GvrArmModel>();

                if (m_leftArm == null)
                {
                    m_leftArm = VRModule.Instance.gameObject.AddComponent <GvrArmModel>();
                }
            }
            m_leftArm.ControllerInputDevice = m_leftDevice;
        }
Пример #17
0
 // Start is called before the first frame update
 void Start()
 {
     narratorAudio = GetComponent <AudioSource>();
     currAudio     = Resources.Load <AudioClip>("Audio/Section1/Intro");
     controller    = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);
     if (hideObjects)
     {
         Reset();
     }
     else
     {
         placed = true;
         ChangeActive(true);
     }
 }
Пример #18
0
 void Start()
 {
     player     = GameObject.FindGameObjectWithTag("Player");
     controller = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);
     boundsHandler.OutOfBoundsListener += OutOfBounds;
     InitStates();
     SetScoreboardPars();
     SetupHoleSigns();
     SetRaycastingEnabled(false);
     MovePlayerToCurrentHoleStart();
     SetState(statePreThrow);
     disc.gameObject.SetActive(false);
     scoreboardController.gameObject.SetActive(false);
     pauseMenu.SetActive(false);
     popup.gameObject.SetActive(false);
 }
Пример #19
0
 public override TBInput.Controller GetActiveController()
 {
     if (TBInput.GetActiveControlType() == TBInput.ControlType.HandControllers)
     {
         if (GvrControllerInput.GetDevice(GvrControllerHand.Dominant).SupportsPositionalTracking)
         {
             return(TBInput.Controller.RHandController);
         }
         else
         {
             return(TBInput.Controller.Mobile3DOFController);
         }
     }
     else
     {
         return(TBInput.Controller.Mobile3DOFController);
     }
 }
    void Start()
    {
        /* Character Controller Boilerplate */
        cc = GetComponent <CharacterController>();

        /* Latch the GVRControllerInputDevice */
        //TODO: If this fails, is there feedback to the user, and
        // is there a retry?  Is there a onConnected callback somewhere?
        device = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);
        if (device == null)
        {
            Debug.LogError($"{logtag} GvrControllerInputDevice is null");
        }
        else
        {
            Debug.LogError($"{logtag} Latched GvrControllerInputDevice.");
        }
    }
Пример #21
0
    void Update()
    {
        TT.text = (h.ToString() + "///" + Camera.main.transform.rotation.eulerAngles.ToString() + GGHHS.ToString());
        X       = Input.GetAxis("Vertical");
        if (GvrControllerInput.GetDevice(GvrControllerHand.Dominant).GetButton(GvrControllerButton.TouchPadTouch))
        {
            GGHHS++;
            h = GvrControllerInput.GetDevice(GvrControllerHand.Dominant).TouchPos;
        }
        if (GvrControllerInput.GetDevice(GvrControllerHand.Dominant).GetButtonUp(GvrControllerButton.TouchPadTouch))
        {
            GGHHS              = 0;
            h                  = Vector2.zero;
            RR.velocity        = Vector3.zero;
            RR.angularVelocity = Vector3.zero;
        }

        RR.AddForce(Camera.main.transform.forward * h.y * Speed);
    }
Пример #22
0
    // Update is called once per frame
    void Update()
    {
        if (isMoving)
        {
            // https://forum.unity.com/threads/solved-moving-object-in-the-direction-of-camera-view.30330/
            // Move the thePlayer in the direction thePointer is facing distance units per second.
            thePlayer.transform.position = thePlayer.transform.position + thePointer.transform.forward * distance * Time.deltaTime;
        }


        // Check IsTouching before retrieving TouchPos. if (GvrControllerInput.IsTouching)
        if (GvrControllerInput.GetDevice(GvrControllerHand.Dominant).GetButton(GvrControllerButton.TouchPadTouch))

        {
            float f;

            // Vector2 touchPos = GvrControllerInput.TouchPos;
            Vector2 touchPos = GvrControllerInput.GetDevice(GvrControllerHand.Dominant).TouchPos;
            f = touchPos.y;
            //Debug.Log("touchPos: " + touchPos.x + "," + touchPos.y + " f: " + f);
            distance = f * 10;
        }
        else
        {
            distance = 10;
        }

        // Click Button(touchpad button)
        // if (GvrControllerInput.ClickButton)
        if (GvrControllerInput.GetDevice(GvrControllerHand.Dominant).GetButton(GvrControllerButton.TouchPadButton))
        {
            isMoving = !isMoving;
        }

        //if (GvrController.AppButtonDown)
        if (GvrControllerInput.GetDevice(GvrControllerHand.Dominant).GetButtonDown(GvrControllerButton.App))
        {
            // Debug.Log("App Button pressed");
            //thePlayer.transform.position = origPos;
            StartLerping();
        }
    }
Пример #23
0
        protected GvrControllerInputDevice GetGoogleControllerID(TBInput.Controller controller)
        {
            if (controller == TBInput.Controller.Active)
            {
                controller = TBInput.GetActiveController();
            }

            switch (controller)
            {
            case TBInput.Controller.LHandController:
                return(GvrControllerInput.GetDevice(GvrControllerHand.Left));

            case TBInput.Controller.RHandController:
                return(GvrControllerInput.GetDevice(GvrControllerHand.Right));

            case TBInput.Controller.Mobile3DOFController:
                return(GvrControllerInput.GetDevice(GvrControllerHand.Dominant));

            default:
                TBLogging.LogError("No controller for " + controller + " exists in TButt's Google VR implementation. Falling back to dominant hand controller.");
                return(GvrControllerInput.GetDevice(GvrControllerHand.Dominant));
            }
        }
Пример #24
0
    private void Awake()
    {
        /*
         */
        WaniQ.Enqueue(new WaniProgress(WaniStatus.start, 2));
        WaniQ.Enqueue(new WaniProgress(WaniStatus.eatyou, 3));
        WaniQ.Enqueue(new WaniProgress(WaniStatus.wani1, 10));
        WaniQ.Enqueue(new WaniProgress(WaniStatus.wani2, 10));
        WaniQ.Enqueue(new WaniProgress(WaniStatus.wani3, 10));
        WaniQ.Enqueue(new WaniProgress(WaniStatus.wani4, 10));
        WaniQ.Enqueue(new WaniProgress(WaniStatus.wani5, 10));
        WaniQ.Enqueue(new WaniProgress(WaniStatus.none, 1.5f));
        WaniQ.Enqueue(new WaniProgress(WaniStatus.angry, 2));
        WaniQ.Enqueue(new WaniProgress(WaniStatus.wani6, 10));
        WaniQ.Enqueue(new WaniProgress(WaniStatus.finish, 7));
        WaniQ.Enqueue(new WaniProgress(WaniStatus.bye, 0));

        gvrController = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);

        //やっぱやめた

        /*
         * TextAsset textAsset = new TextAsset();
         * textAsset = Resources.Load("timing", typeof(TextAsset)) as TextAsset;
         * string text = textAsset.text;
         * string[] line = text.Split('\n');
         * for (int i = 0; i < line.Length; i++)
         * {
         *  string[] col = line[i].Split(',');
         *  timing.Add(int.Parse(col[0]), int.Parse(col[1]));
         * }
         */

        aud = GetComponent <AudioSource>();

        Menu.SetActive(false);
    }
Пример #25
0
    // Update is called once per frame
    void Update()
    {
        //fire gun
        if (GvrControllerInput.GetDevice(GvrControllerHand.Dominant).GetButtonDown(GvrControllerButton.TouchPadButton) && Globals.canFireGun && (Globals.shotsLeft > 0 || uiController.isAtSelectionMenu()))
        {
            //reduce shot count
            if (!uiController.isAtSelectionMenu())
            {
                Globals.shotsLeft--;
                uiController.StrikeShell(Mathf.Abs(Globals.shotsLeft - 2));
            }

            //cast ray from gun
            FireRayCast();

            //play FX
            gunAnimator.SetTrigger("Fire");
            gunFireParticles.Play();
            shotSound.Play();

            //disable firing again until animation finishes
            Globals.canFireGun = false;
        }
    }
Пример #26
0
 /// Returns the `GvrControllerInputDevice` that triggered the event.
 public static GvrControllerInputDevice GvrGetControllerInputDevice(this PointerEventData pointerEventData)
 {
     return(GvrControllerInput.GetDevice((GvrControllerHand)pointerEventData.pointerId));
 }
 // Use this for initialization
 void Start()
 {
     lineRenderer = GetComponent <LineRenderer>();
     controller   = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);
 }
Пример #28
0
        private void UpdateStatusMessage()
        {
            if (messageText == null || messageCanvas == null)
            {
                return;
            }

#if !UNITY_ANDROID && !UNITY_IOS
            messageText.text = NON_GVR_PLATFORM;
            messageCanvas.SetActive(true);
            return;
#else
#if UNITY_EDITOR
            if (!UnityEditor.PlayerSettings.virtualRealitySupported)
            {
                messageText.text = VR_SUPPORT_NOT_CHECKED;
                messageCanvas.SetActive(true);
                return;
            }
#endif  // UNITY_EDITOR

            bool isVrSdkListEmpty = !playerSettingsHasCardboard() && !playerSettingsHasDaydream();
            if (!isDaydream)
            {
                if (messageCanvas.activeSelf)
                {
                    messageText.text = EMPTY_VR_SDK_WARNING_MESSAGE;
                    messageCanvas.SetActive(isVrSdkListEmpty);
                }

                return;
            }

            string vrSdkWarningMessage =
                isVrSdkListEmpty ? EMPTY_VR_SDK_WARNING_MESSAGE : "";
            string controllerMessage = "";
            GvrPointerGraphicRaycaster graphicRaycaster =
                messageCanvas.GetComponent <GvrPointerGraphicRaycaster>();
            GvrControllerInputDevice dominantDevice =
                GvrControllerInput.GetDevice(GvrControllerHand.Dominant);
            GvrConnectionState connectionState = dominantDevice.State;

            // This is an example of how to process the controller's state to display a status
            // message.
            switch (connectionState)
            {
            case GvrConnectionState.Connected:
                break;

            case GvrConnectionState.Disconnected:
                controllerMessage = CONTROLLER_DISCONNECTED_MESSAGE;
                messageText.color = Color.white;
                break;

            case GvrConnectionState.Scanning:
                controllerMessage = CONTROLLER_SCANNING_MESSAGE;
                messageText.color = Color.cyan;
                break;

            case GvrConnectionState.Connecting:
                controllerMessage = CONTROLLER_CONNECTING_MESSAGE;
                messageText.color = Color.yellow;
                break;

            case GvrConnectionState.Error:
                controllerMessage = "ERROR: " + dominantDevice.ErrorDetails;
                messageText.color = Color.red;
                break;

            default:
                // Shouldn't happen.
                Debug.LogError("Invalid controller state: " + connectionState);
                break;
            }

            messageText.text = string.Format("{0}\n{1}", vrSdkWarningMessage, controllerMessage);
            if (graphicRaycaster != null)
            {
                graphicRaycaster.enabled =
                    !isVrSdkListEmpty || connectionState != GvrConnectionState.Connected;
            }

            messageCanvas.SetActive(isVrSdkListEmpty ||
                                    (connectionState != GvrConnectionState.Connected));
#endif  // !UNITY_ANDROID && !UNITY_IOS
        }
Пример #29
0
 // Start is called before the first frame update
 void Start()
 {
     controller          = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);
     resetCanvas.enabled = false;
 }
Пример #30
0
    public float sphereRadius = 1.0f;               // This should match the radius of the globe, geocoding may not work if it does not

    void Start()
    {
        _dominantController  = GvrControllerInput.GetDevice(GvrControllerHand.Dominant);
        _previousOrientation = _dominantController.Orientation * Vector3.forward;
    }