/// <summary> /// completely restores the UFPS player hierarchy for desktop mode play. called /// from this script's 'OnDisable' /// </summary> protected virtual void RestorePlayerHierarchy() { // prevent nullrefs if scene is being cleared if (m_AppQuitting) { return; } // don't do anything if the hierarchy hasn't been modified if (CenterEyeAnchor == null) { return; } // restore FPCamera if (FPCamera != null) { FPCamera.PositionOffset = m_FPCameraOffsetBak; // reenable Unity camera component if (FPCamera.Camera != null) { FPCamera.Camera.enabled = true; FPCamera.Refresh(); } } // reactivate weapon camera (if any) if (WeaponCamera != null) { vp_Utility.Activate(WeaponCamera.gameObject, true); if (FPCamera != null) { FPCamera.SnapSprings(); FPCamera.SnapZoom(); } if (WeaponHandler != null) { if (WeaponHandler.CurrentWeapon != null) { WeaponHandler.CurrentWeapon.ResetState(); } } if (FPCamera != null) { FPCamera.Refresh(); } } // reactivate player body // NOTE: if player body has a foot fx handler, this should reenable it if (BodyAnimator != null) { vp_Utility.Activate(BodyAnimator.gameObject, true); } // disable our own foot fx handler if (VRFootFXHandler != null) { VRFootFXHandler.enabled = false; } // reenable desktop audio listener if (FPPlayer != null) { AudioListener[] desktopAudioListeners = FPPlayer.GetComponentsInChildren <AudioListener>(true); bool done = false; foreach (AudioListener a in desktopAudioListeners) { if (!done) // only enable a single audio listener { a.enabled = true; done = true; } } } // disable our own audio listener if (VRAudioListener != null) { VRAudioListener.enabled = false; } // reenable the UFPS HUD (if any) if (DesktopHUD != null) { DesktopHUD.enabled = true; } // unhide the UFPS crosshair if (DesktopCrosshair != null) { DesktopCrosshair.Hide = false; } // reallow vp_FPInput from processing pitch and yaw if (FPInput != null) { FPInput.MouseLookMutePitch = false; FPInput.MouseLookMuteYaw = false; } // reenable all camera motion settings if (FPCamera != null) { FPCamera.MuteBob = false; FPCamera.MuteEarthquakes = false; FPCamera.MuteShakes = false; FPCamera.MuteRoll = false; FPCamera.MuteFallImpacts = false; FPCamera.MuteBombShakes = false; FPCamera.MuteGroundStomps = false; } if (FPController != null) { FPController.PhysicsForceDamping = m_ControllerForceDampingBak; FPController.PhysicsSlopeSlidiness = m_ControllerSlopeSlidinessBak; } if (FPPlayer != null) { FPPlayer.RefreshActivityStates(); } }
/// <summary> /// strips and modifies the UFPS player hierarchy so it works with the various /// 'vp_VRCameraManager' logics. called from this script's 'OnEnable' /// </summary> protected virtual IEnumerator ModifyPlayerHierarchy() { yield return(new WaitForEndOfFrame()); if (m_AppQuitting) { yield return(null); } // disable the Unity camera on the FPCamera gameobject because the // OVRCameraRig has its own cameras if ((FPCamera != null) && (FPCamera.Camera != null)) { FPCamera.Camera.enabled = false; } if (FPController != null) { m_ControllerForceDampingBak = FPController.PhysicsForceDamping; m_ControllerSlopeSlidinessBak = FPController.PhysicsSlopeSlidiness; } // disable weapon camera because it does not apply / work in VR if (WeaponCamera != null) { vp_Utility.Activate(WeaponCamera.gameObject, false); FPCamera.SnapSprings(); FPCamera.SnapZoom(); if (WeaponHandler.CurrentWeapon != null) { WeaponHandler.CurrentWeapon.ResetState(); } FPCamera.Refresh(); } // disable local player body because it does not have advanced enough IK // for VR (at least not until UFPS 2) // NOTE: this will also disable any vp_PlayerFootFXHandler placed on the body object if (BodyAnimator != null) { vp_Utility.Activate(BodyAnimator.gameObject, false); } // enable the VR foot fx handler (if any - placed directly on the controller object) if (VRFootFXHandler != null) { VRFootFXHandler.enabled = true; } // disable all audio listeners on the player and enable our own if (VRAudioListener != null) { VRAudioListener.enabled = true; } AudioListener[] desktopAudioListeners = FPPlayer.GetComponentsInChildren <AudioListener>(true); foreach (AudioListener a in desktopAudioListeners) { a.enabled = false; } // disable the UFPS HUD (if any) if (DesktopHUD != null) { DesktopHUD.enabled = false; } // hide the UFPS crosshair if (DesktopCrosshair != null) { DesktopCrosshair.Hide = true; } }