mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-04 07:19:22 +00:00
[DesktopVRSwitch] Testing
This commit is contained in:
parent
03514305be
commit
61a45f97bc
30 changed files with 957 additions and 524 deletions
38
DesktopVRSwitch/VRModeTrackers/PlayerSetupTracker.cs
Normal file
38
DesktopVRSwitch/VRModeTrackers/PlayerSetupTracker.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using ABI_RC.Core.Player;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class PlayerSetupTracker : VRModeTracker
|
||||
{
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnPostSwitch(bool intoVR)
|
||||
{
|
||||
PlayerSetup _playerSetup = PlayerSetup.Instance;
|
||||
if (_playerSetup == null)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Error("Error while getting PlayerSetup!");
|
||||
return;
|
||||
}
|
||||
DesktopVRSwitch.Logger.Msg("Switching active PlayerSetup camera rigs. Updating Desktop camera FOV.");
|
||||
|
||||
_playerSetup.desktopCameraRig.SetActive(!intoVR);
|
||||
_playerSetup.vrCameraRig.SetActive(intoVR);
|
||||
|
||||
// This might error if we started in VR.
|
||||
// '_cam' is not set until Start().
|
||||
CVR_DesktopCameraController.UpdateFov();
|
||||
|
||||
// UICamera has a script that copies the FOV from the desktop cam.
|
||||
// Toggling the cameras on/off resets the aspect ratio,
|
||||
// so when rigs switch, that is already handled.
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue