void Start() { locomotion = SceneHelpers.FindObjectOfType <FirstPersonTunnelingLocomotion>(true); Assert.IsNotNull(locomotion); controller = SceneHelpers.FindObjectOfType <GvrTrackedController>(true); Assert.IsNotNull(controller); }
// 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 }
void Start() { controller = SceneHelpers.FindObjectOfType <GvrTrackedController>(true); Assert.IsNotNull(controller); teleport = SceneHelpers.FindObjectOfType <TeleportController>(true); Assert.IsNotNull(teleport); }
void Start() { controller = SceneHelpers.FindObjectOfType <GvrTrackedController>(true); Assert.IsNotNull(controller); pointer = controller.GetComponentInChildren <ObjectManipulationPointer>(true); Assert.IsNotNull(pointer); }
void Start() { constellationMenu = SceneHelpers.FindObjectOfType <ConstellationMenuRoot>(true); Assert.IsNotNull(constellationMenu); controller = SceneHelpers.FindObjectOfType <GvrTrackedController>(true); Assert.IsNotNull(controller); pointer = controller.GetComponentInChildren <GvrLaserPointer>(true); Assert.IsNotNull(pointer); }
// Hook this up to Event Trigger PointerUp. public void GripEndGrab(BaseEventData eventData) { PointerEventData ptrEventData = eventData as PointerEventData; if (ptrEventData != null && (ptrEventData.GvrGetButtonsDown() & GvrControllerButton.Grip) != 0) { grabController = null; isLockedToController = false; } }
// Hook this up to Event Trigger PointerDown. public void GripStartGrab(BaseEventData eventData) { PointerEventData ptrEventData = eventData as PointerEventData; if (ptrEventData != null && (ptrEventData.GvrGetButtonsDown() & GvrControllerButton.Grip) != 0) { grabController = GvrPointerInputModule.Pointer.GetComponentInParent <GvrTrackedController>(); isLockedToController = false; } }
void Awake() { if (trackedController == null) { Debug.LogWarning("Assign controller"); GvrTrackedController left = (GvrTrackedController)GameObject.Find("GvrControllerPointer"); if (left != null) { trackedController = left; Debug.Log("FOUND!"); } } }
/// <summary> /// Unity method that runs at the beginning of the execution. /// </summary> void Start() { bool mimicsRes = false; controller = SceneHelpers.FindObjectOfType <GvrTrackedController>(true); Assert.IsNotNull(controller); teleport = SceneHelpers.FindObjectOfType <TeleportController>(true); Assert.IsNotNull(teleport); pointer = controller.GetComponentInChildren <ObjectManipulationPointer>(true); Assert.IsNotNull(pointer); mimicsRes = FindObjectsOfType <MainCameraMimic>().UpdateMainCameraRef(); Assert.IsTrue(mimicsRes); }
protected override void Awake() { base.Awake(); positionedCharacter = SceneHelpers.FindObjectOfType <BasePositionedCharacter>(true); Assert.IsNotNull(positionedCharacter); controller = SceneHelpers.FindObjectOfType <GvrTrackedController>(true); Assert.IsNotNull(controller); pointer = controller.GetComponentInChildren <CharacterPositionPointer>(true); Assert.IsNotNull(pointer); chaseCam = SceneHelpers.FindObjectOfType <ChaseCam>(true); Assert.IsNotNull(chaseCam); }
void Awake() { if (trackedController == null) { Debug.LogWarning("Assign controller"); GvrTrackedController left = (GvrTrackedController)GameObject.Find("GvrControllerPointer"); if (left != null) { trackedController = left; Debug.Log("FOUND!"); } } if (lineRenderer == null) { Debug.LogWarning("Assign a line renderer in the inspector!"); lineRenderer = gameObject.AddComponent <LineRenderer>(); lineRenderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off; lineRenderer.receiveShadows = false; lineRenderer.widthMultiplier = 0.02f; } }
// Retrieve controller parameters from a Daydream controller. private void GetDaydreamControllerStatus(GameObject controllerObject, bool isLeft, out bool trigger, out Vector3 direction, out bool touchpad, out Vector2 touchposition, out bool backButton) { trigger = false; direction = new Vector3(0, 0, 0); touchpad = false; touchposition = new Vector2(0, 0); backButton = false; GvrTrackedController track = controllerObject.GetComponent <GvrTrackedController> (); if (track != null) { GvrControllerInputDevice inputDevice = track.ControllerInputDevice; if (inputDevice != null) { trigger = inputDevice.GetButton(GvrControllerButton.TouchPadButton); backButton = inputDevice.GetButton(GvrControllerButton.App); direction = controllerObject.transform.forward; touchpad = inputDevice.GetButton(GvrControllerButton.TouchPadTouch); touchposition = inputDevice.TouchPos; } } }