internal void Update() { if (lastUpdatedFrameCount != Time.frameCount) { if (!valid) { Debug.LogError("Using an invalid GvrControllerInputDevice. Please acquire a new one from GvrControllerInput.GetDevice()."); return; } // The controller state must be updated prior to any function using the // controller API to ensure the state is consistent throughout a frame. lastUpdatedFrameCount = Time.frameCount; GvrConnectionState oldState = State; controllerProvider.ReadState(controllerState, controllerId); UpdateTouchPosCentered(); #if UNITY_EDITOR if (IsDominantHand) { // Make sure the EditorEmulator is updated immediately. if (GvrEditorEmulator.Instance != null) { GvrEditorEmulator.Instance.UpdateEditorEmulation(); } } #endif // UNITY_EDITOR if (OnStateChanged != null && State != oldState) { OnStateChanged(State, oldState); } } }
private void OnControllerStateChanged(GvrConnectionState state, GvrConnectionState oldState) { if (isDeactivatedWhenDisconnected && enabled) { gameObject.SetActive(state == GvrConnectionState.Connected); } }
void Update() { if (lastUpdatedFrameCount != Time.frameCount) { // The controller state must be updated prior to any function using the // controller API to ensure the state is consistent throughout a frame. lastUpdatedFrameCount = Time.frameCount; GvrConnectionState oldState = State; controllerProvider.ReadState(controllerState); UpdateTouchPosCentered(); if (OnStateChanged != null && State != oldState) { OnStateChanged(State, oldState); } if (OnControllerInputUpdated != null) { OnControllerInputUpdated(); } if (OnPostControllerInputUpdated != null) { OnPostControllerInputUpdated(); } } }
public void CopyFrom(ControllerState other) { connectionState = other.connectionState; apiStatus = other.apiStatus; orientation = other.orientation; gyro = other.gyro; accel = other.accel; isTouching = other.isTouching; touchPos = other.touchPos; touchDown = other.touchDown; touchUp = other.touchUp; recentered = other.recentered; clickButtonState = other.clickButtonState; clickButtonDown = other.clickButtonDown; clickButtonUp = other.clickButtonUp; appButtonState = other.appButtonState; appButtonDown = other.appButtonDown; appButtonUp = other.appButtonUp; homeButtonDown = other.homeButtonDown; homeButtonUp = other.homeButtonUp; homeButtonState = other.homeButtonState; errorDetails = other.errorDetails; gvrPtr = other.gvrPtr; isCharging = other.isCharging; batteryLevel = other.batteryLevel; }
private void OnControllerStateChanged(GvrConnectionState state, GvrConnectionState oldState) { bool controllerconnect = state == GvrConnectionState.Connected; #if SVR_USE_GAZE SetGazeInputActive(!controllerconnect); SetControllerInputActive(controllerconnect); #endif }
private void OnControllerStateChanged(GvrConnectionState state, GvrConnectionState oldState) { if (isDeactivatedWhenDisconnected && enabled) { gameObject.SetActive(state == GvrConnectionState.Connected); if (gameObject.activeSelf) { GvrPointerInputModule.Pointer = GetComponentInChildren <GvrBasePointer>(); } } }
private void OnControllerStateChanged(GvrConnectionState state, GvrConnectionState oldState) { if (enabled) { gameObject.SetActive(state != GvrConnectionState.Connected); SVR.AtwAPI.ShowDualSurface(state != GvrConnectionState.Connected); if (gameObject.activeSelf) { GvrPointerInputModule.Pointer = GetComponentInChildren <GvrBasePointer>(); } } }
public void CopyFrom(ControllerState other) { connectionState = other.connectionState; apiStatus = other.apiStatus; orientation = other.orientation; position = other.position; gyro = other.gyro; accel = other.accel; touchPos = other.touchPos; recentered = other.recentered; buttonsState = other.buttonsState; buttonsDown = other.buttonsDown; buttonsUp = other.buttonsUp; errorDetails = other.errorDetails; gvrPtr = other.gvrPtr; isCharging = other.isCharging; batteryLevel = other.batteryLevel; }
public void CopyFrom(ControllerState other) { connectionState = other.connectionState; orientation = other.orientation; gyro = other.gyro; accel = other.accel; isTouching = other.isTouching; touchPos = other.touchPos; touchDown = other.touchDown; touchUp = other.touchUp; recentering = other.recentering; recentered = other.recentered; clickButtonState = other.clickButtonState; clickButtonDown = other.clickButtonDown; clickButtonUp = other.clickButtonUp; appButtonState = other.appButtonState; appButtonDown = other.appButtonDown; appButtonUp = other.appButtonUp; errorDetails = other.errorDetails; }
void Update() { //datld: add double click check if (lastUpdatedFrameCount != Time.frameCount) { // The controller state must be updated prior to any function using the // controller API to ensure the state is consistent throughout a frame. lastUpdatedFrameCount = Time.frameCount; GvrConnectionState oldState = State; controllerProvider.ReadState(controllerState); UpdateTouchPosCentered(); #if UNITY_EDITOR // Make sure the EditorEmulator is updated immediately. if (GvrEditorEmulator.Instance != null) { GvrEditorEmulator.Instance.UpdateEditorEmulation(); } #endif // UNITY_EDITOR if (OnStateChanged != null && State != oldState) { OnStateChanged(State, oldState); } if (OnControllerInputUpdated != null) { OnControllerInputUpdated(); } if (OnPostControllerInputUpdated != null) { OnPostControllerInputUpdated(); } } }
private void OnControllerStateChanged(GvrConnectionState state, GvrConnectionState oldState) { gameObject.SetActive(state == GvrConnectionState.Connected); }
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 }
void StateRespond(GvrConnectionState state, GvrConnectionState oldState) { Debug.Log(string.Format("StateRespond. New: {0}, Old: {1}", state, oldState)); }