public void ChangePreferredHandLeft(SettingPanel settingPanel) { PreferredHand pref = XRSettings.Instance.settings.PreferredHand; PreferredHand newPref = pref; if (!XRSettings.Instance.settings.ControllersInUse) { XRSettings.Instance.ChangePreferredHand(newPref); settingPanel.SetText("Main Device: " + newPref.ToString()); return; } //Can't change to controllers if no controllers are connected! if (pref == PreferredHand.Hmd && XRSettings.Instance.settings.RightControllerConnected) { newPref = PreferredHand.Right; } else if (pref == PreferredHand.Right && XRSettings.Instance.settings.LeftControllerConnected) { newPref = PreferredHand.Left; } else if (pref == PreferredHand.Left) { newPref = PreferredHand.Hmd; } XRSettings.Instance.ChangePreferredHand(newPref); settingPanel.SetText("Main Device: " + newPref.ToString()); }
/// <summary> /// This function is used to change the preferred hand "main hand", /// which user wishes to use for input and actions. /// </summary> /// <param name="newHand">New preferred hand</param> public void ChangePreferredHand(PreferredHand newHand) { if (settings.CurrentHand != newHand) { settings.PreferredHand = newHand; } }
public void ChangePreferredHandRight(SettingPanel settingPanel) { PreferredHand pref = XRSettings.Instance.settings.PreferredHand; PreferredHand newPref = pref; //Debug.Log(newPref + " " + (int)newPref + " " + (PreferredHand)newPref); if (pref == PreferredHand.Hmd && XRSettings.Instance.settings.LeftControllerConnected) { newPref = PreferredHand.Left; } else if (pref == PreferredHand.Left && XRSettings.Instance.settings.RightControllerConnected) { newPref = PreferredHand.Right; } else if (pref == PreferredHand.Right) { newPref = PreferredHand.Hmd; } //Debug.Log(newPref + " " + (int)newPref + " " + (PreferredHand)newPref); XRSettings.Instance.ChangePreferredHand(newPref); settingPanel.SetText("Main Device: " + newPref.ToString()); }
/// <summary> /// This function is called, /// when Game settings change. /// Checks the variables of XRMovementSwitch to match with new settings, /// and changes the movement type to match the new settings selected movement type. /// Also calls the StartState function and ExitState function on current movement type. /// </summary> /// <param name="newSettings"></param> public void CheckMovementType(GameSettings newSettings) { if (preferredHand != newSettings.CurrentHand) { preferredHand = newSettings.CurrentHand; } if (usingControllers != newSettings.ControllersInUse) { usingControllers = newSettings.ControllersInUse; } if (currentMovementType == newSettings.MovementType && currentXRMovement != null) { return; } if (currentXRMovement != null && currentMovementType != newSettings.MovementType) { currentXRMovement.ExitState(); } Debug.Log(this + " Changed movement type!"); SetCurrentXRMovementType(newSettings.MovementType); currentMovementType = newSettings.MovementType; currentXRMovement.StartState(this); ready = true; }
/// <summary> /// Used to get controller transform matching the preferredhand enum. /// </summary> /// <param name="hand">Used to check the correct transform</param> /// <returns>the transform of left or right controller</returns> public Transform GetControllerTransform(PreferredHand hand) { Transform c = rightController.transform; if (hand == PreferredHand.Right) { c = rightController.transform; } if (hand == PreferredHand.Left) { c = leftController.transform; } return(c); }
/// <summary> /// Used to fetch controller matching the preferredhand enum. /// </summary> /// <param name="hand">Used to check the inputdevice XRNode</param> /// <returns>The Inputdevice left or right controller</returns> public InputDevice GetControllerDevice(PreferredHand hand) { XRNode node = XRNode.RightHand; if (hand == PreferredHand.Right) { node = XRNode.RightHand; } if (hand == PreferredHand.Left) { node = XRNode.LeftHand; } return(InputDevices.GetDeviceAtXRNode(node)); }
/// <summary> /// This function Returns raw true or false primary button press, depending on the parameter Preferredhand. /// </summary> /// <param name="hand">The Hand which press is checked</param> /// <returns>returns bool of button being pressed or not</returns> public bool GetPrimaryButtonControlPress(PreferredHand hand) { if (hand == PreferredHand.Left) { return(leftControllerPrimaryButtonPress); } if (hand == PreferredHand.Right) { return(rightControllerPrimaryButtonPress); } if (hand == PreferredHand.Hmd) { return(hmdPrimaryButtonPress); } return(false); }
/// <summary> /// This function is called, /// when settings are changed, /// Changes the prederred hand to new settings hand. /// </summary> /// <param name="settings"></param> public void SettingChange(GameSettings settings) { preferredHand = settings.CurrentHand; Debug.Log(this.gameObject.name + " Hand changed to: " + preferredHand.ToString()); }