void RpcInputDirty(bool triggerPressed, float triggerPressure, bool padTopPressed, bool padLeftPressed, bool padRightPressed, bool padBottomPressed, bool padCentrePressed, bool padTouched, bool padPressed, Vector2 padPosition, bool gripPressed, bool menuPressed, bool axPressed, bool isLeftHand) { if (hasAuthority) { return; } GameObject targetObject = isLeftHand ? leftHand : rightHand; if (targetObject == null) { return; } VRInputRemote input = targetObject.GetComponent <VRInputRemote>(); if (input == null) { return; } input._triggerPressed = triggerPressed; input._triggerPressure = triggerPressure; input._padTopPressed = padTopPressed; input._padLeftPressed = padLeftPressed; input._padRightPressed = padRightPressed; input._padBottomPressed = padBottomPressed; input._padCentrePressed = padCentrePressed; input._padTouched = padTouched; input._padPressed = padPressed; input._padPosition = padPosition; input._gripPressed = gripPressed; input._menuPressed = menuPressed; input._axPressed = axPressed; }
/// <summary> /// Strip the SteamVR or Oculus camera rig and add the remote scripts /// for receiving input. /// </summary> public void ConvertToRemoteRig() { if (remoteRig) { return; } remoteRig = true; Component[] components = GetComponentsInChildren <Component>(true); foreach (Component comp in components) { if (comp == null || !CanDestroyType(comp) || !comp.gameObject.CanDestroy(comp.GetType())) { continue; } if (comp.GetType().IsSubclassOf(typeof(VRInput))) { VRInputRemote inputRemote = comp.gameObject.AddComponent <VRInputRemote>(); // Initial Sync VRInput originalInput = (VRInput)comp; inputRemote.VRActions = originalInput.VRActions; inputRemote._isSteamVR = originalInput.isSteamVR(); inputRemote._hmdType = originalInput.hmdType; inputRemote._leftHand = originalInput.LeftHand; if (originalInput.LeftHand) { leftHand = comp.gameObject; } else { rightHand = comp.gameObject; } inputRemote.triggerKey = originalInput.triggerKey; inputRemote.padTop = originalInput.padTop; inputRemote.padLeft = originalInput.padLeft; inputRemote.padRight = originalInput.padRight; inputRemote.padBottom = originalInput.padBottom; inputRemote.padCentre = originalInput.padCentre; inputRemote.padTouch = originalInput.padTouch; inputRemote.gripKey = originalInput.gripKey; inputRemote.menuKey = originalInput.menuKey; inputRemote.AXKey = originalInput.AXKey; inputRemote.triggerKeyOculus = originalInput.triggerKeyOculus; inputRemote.padTopOculus = originalInput.padTopOculus; inputRemote.padLeftOculus = originalInput.padLeftOculus; inputRemote.padRightOculus = originalInput.padRightOculus; inputRemote.padBottomOculus = originalInput.padBottomOculus; inputRemote.padCentreOculus = originalInput.padCentreOculus; inputRemote.padTouchOculus = originalInput.padTouchOculus; inputRemote.gripKeyOculus = originalInput.gripKeyOculus; inputRemote.menuKeyOculus = originalInput.menuKeyOculus; inputRemote.AXKeyOculus = originalInput.AXKeyOculus; } if (comp.GetType().IsSubclassOf(typeof(VRInteractor))) { VRInteractorRemote interactorRemote = comp.gameObject.AddComponent <VRInteractorRemote>(); //Initial Sync VRInteractor originalInteractor = (VRInteractor)comp; interactorRemote.useHoverLine = originalInteractor.useHoverLine; if (originalInteractor.useHoverLine) { interactorRemote.hoverLineMat = originalInteractor.hoverLineMat; } interactorRemote.hideControllersWhileHolding = originalInteractor.hideControllersWhileHolding; interactorRemote.controllerAnchor = originalInteractor.controllerAnchor; interactorRemote.controllerAnchorOffset = originalInteractor.controllerAnchorOffset; interactorRemote.ikTarget = originalInteractor.ikTarget; interactorRemote.forceGrabDirection = originalInteractor.forceGrabDirection; interactorRemote.forceGrabDistance = originalInteractor.forceGrabDistance; } Destroy(comp); } foreach (Component comp in components) { if (comp == null || !CanDestroyType(comp)) { continue; } Destroy(comp); } if (leftHand != null) { leftHand.SetActive(true); } if (rightHand != null) { rightHand.SetActive(true); } }