void Awake() { if (instances.Length > 0) { Debug.LogError("More than one active GvrControllerInput instance was found in your scene. " + "Ensure that there is only one GvrControllerInput."); this.enabled = false; return; } if (controllerProvider == null) { controllerProvider = ControllerProviderFactory.CreateControllerProvider(this); } handedness = GvrSettings.Handedness; int controllerCount = 2; instances = new GvrControllerInputDevice[controllerCount]; for (int i = 0; i < controllerCount; i++) { instances[i] = new GvrControllerInputDevice(controllerProvider, i); } if (onDevicesChangedInternal != null) { onDevicesChangedInternal(); } // Keep screen on here, since GvrControllerInput must be in any GVR scene in order to enable // controller capabilities. Screen.sleepTimeout = SleepTimeout.NeverSleep; }
void Update() { // If handedness changed, place Tooltips on the correct side of the controller. if (handedness != GvrSettings.Handedness) { handedness = GvrSettings.Handedness; ShowRightLeft(); } // Show tooltips if the controller is in the FOV or if the controller angle is high enough. float controllerAngleToFront = Vector3.Angle(GvrController.Orientation * Vector3.down, GetHeadForward()); bVisible = (controllerAngleToFront < 50.0f); float currentAlpha = canvasGroup.alpha; if (bVisible) { currentAlpha = Mathf.Min(1.0f, currentAlpha + DELTA_ALPHA * Time.deltaTime); } else { currentAlpha = Mathf.Max(0.0f, currentAlpha - DELTA_ALPHA * Time.deltaTime); } currentAlpha = Mathf.Min(currentAlpha, GvrArmModel.Instance.alphaValue); canvasGroup.alpha = currentAlpha; }
void OnGUI() { // Label for Controller Emulator settings EditorGUILayout.LabelField("Controller Emulator", EditorStyles.boldLabel); // Option to control Handedness GvrSettings.UserPrefsHandedness oldHandedness = GvrSettings.Handedness; GvrSettings.Handedness = (GvrSettings.UserPrefsHandedness)EditorGUILayout.EnumPopup("Handedness", oldHandedness); if (oldHandedness != GvrSettings.Handedness) { UnityEditorInternal.InternalEditorUtility.RepaintAllViews(); } }
/// Returns true if the tooltip should display on the left side of the controller. /// This will change based on the handedness of the controller, as well as if the /// tooltip is set to display inside or outside. public bool IsTooltipOnLeft() { bool isInside = IsTooltipInside(); GvrSettings.UserPrefsHandedness handedness = GvrSettings.Handedness; if (handedness == GvrSettings.UserPrefsHandedness.Left) { return(!isInside); } else { return(isInside); } }
protected virtual void UpdateHandedness() { // Update user handedness if the setting has changed GvrSettings.UserPrefsHandedness handedness = GvrSettings.Handedness; // Determine handedness multiplier. handedMultiplier.Set(0, 1, 1); if (handedness == GvrSettings.UserPrefsHandedness.Right) { handedMultiplier.x = 1.0f; } else if (handedness == GvrSettings.UserPrefsHandedness.Left) { handedMultiplier.x = -1.0f; } }
void OnApplicationPause(bool paused) { if (null == controllerProvider) { return; } if (paused) { controllerProvider.OnPause(); } else { handedness = GvrSettings.Handedness; controllerProvider.OnResume(); } }
private static int toIndex(GvrSettings.UserPrefsHandedness value) { switch (value) { case GvrSettings.UserPrefsHandedness.Error: return(0); case GvrSettings.UserPrefsHandedness.Right: return(1); case GvrSettings.UserPrefsHandedness.Left: return(2); default: return(0); } }
private void UpdateHandedness() { // Update user handedness if the setting has changed GvrSettings.UserPrefsHandedness handedness = GvrSettings.Handedness; // Determine handedness multiplier. handedMultiplier.Set(0, 1, 1); if (handedness == GvrSettings.UserPrefsHandedness.Right) { handedMultiplier.x = 1.0f; } else if (handedness == GvrSettings.UserPrefsHandedness.Left) { handedMultiplier.x = -1.0f; } // Place the shoulder in anatomical positions based on the height and handedness. shoulderRotation = Quaternion.identity; }
void Update () { // If handedness changed, place Tooltips on the correct side of the controller. if (handedness != GvrSettings.Handedness) { handedness = GvrSettings.Handedness; ShowRightLeft(); } // Show tooltips if the controller is in the FOV or if the controller angle is high enough. float controllerAngleToFront = Vector3.Angle(GvrController.Orientation * Vector3.down, GetHeadForward()); bVisible = (controllerAngleToFront < 50.0f); float currentAlpha = canvasGroup.alpha; if (bVisible) { currentAlpha = Mathf.Min(1.0f, currentAlpha + DELTA_ALPHA * Time.deltaTime); } else { currentAlpha = Mathf.Max(0.0f, currentAlpha - DELTA_ALPHA * Time.deltaTime); } currentAlpha = Mathf.Min(currentAlpha, GvrArmModel.Instance.alphaValue); canvasGroup.alpha = currentAlpha; }