/// <summary> /// Swaps the visibility of controllers depending on which controller a user has selected /// </summary> /// <param name="controller">Which controller is the active controller at the present</param> private void Swap(OVRPlugin.Controller controller) { bool swap = (controller == OVRPlugin.Controller.Hands); //if hands then true otherwise false if (swap) { handInputEventEnabled?.Invoke(); } else { handInputEventDisabled?.Invoke(); } hands.Show(swap); if (controllers != null) { controllers.Show(!swap); } if ( swap && ovrRig ) { // if hands, because the hand data forward is incorrectly offset by 90 degrees ovrRig.LeftController.transform.localRotation = Quaternion.Euler(0f , 90f , 0f); ovrRig.RightController.transform.localRotation = Quaternion.Euler(0f, 90f, 0f); } else if ( ovrRig) { //if controllers, reset back to identity ovrRig.LeftController.transform.localRotation = Quaternion.identity; ovrRig.RightController.transform.localRotation = Quaternion.identity; } }
// Update is called once per frame void Update() { OVRPlugin.Controller control = OVRPlugin.GetActiveController(); //get current controller scheme if (currControl != control) //if current controller is different from previous { Swap(control); //swap shown controllers currControl = control; //save current controller scheme } }
// Update is called once per frame private void Update() { OVRPlugin.Controller control = OVRPlugin.GetActiveController(); //get current controller scheme if (currControl != control) { //if current controller (hand or controller) is different from previous Swap(control); //swap shown controllers (hand or controller) currControl = control; //save current controller (hand or controller) scheme } PingMe?.Invoke(this); }
/// <summary> /// Swaps the visibility of controllers depending on which controller a user has selected /// </summary> /// <param name="controller">Which controller is the active controller at the present</param> private void Swap(OVRPlugin.Controller controller) { bool swap = (controller == OVRPlugin.Controller.Hands); //if hands then true otherwise false hands.Show(swap); controllers.Show(!swap); if (swap && ovrRig) // if hands, because the hand data forward is incorrectly offset by 90 degrees { ovrRig.LeftController.transform.localRotation = Quaternion.Euler(0f, 90f, 0f); ovrRig.RightController.transform.localRotation = Quaternion.Euler(0f, 90f, 0f); } else if (ovrRig) //if controllers, reset back to identity { ovrRig.LeftController.transform.localRotation = Quaternion.identity; ovrRig.RightController.transform.localRotation = Quaternion.identity; } }
private OVRPlugin.Controller currControl = OVRPlugin.Controller.None; //variable to keep tracking of current input mechanism // Start is called before the first frame update private void Start() { currControl = OVRPlugin.GetActiveController(); //set active Swap(currControl); //set defaults }