Handling of "VR <-> Desktop" switch, attempt one

This commit is contained in:
SDraw 2024-01-29 23:11:01 +03:00
parent c2a219dfa3
commit 66b448a2c3
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5
20 changed files with 356 additions and 77 deletions

View file

@ -1,4 +1,5 @@
using ABI_RC.Core.Player;
using ABI_RC.Systems.VRModeSwitch;
using System.Collections;
using UnityEngine;
@ -87,6 +88,9 @@ namespace ml_lme
OnVisualHandsChange(Settings.VisualHands);
OnTrackingModeChange(Settings.TrackingMode);
OnRootAngleChange(Settings.RootAngle);
VRModeSwitchEvents.OnInitializeXR.AddListener(this.OnSwitchToVR);
VRModeSwitchEvents.OnDeinitializeXR.AddListener(this.OnSwitchToDesktop);
}
IEnumerator WaitForLocalPlayer()
@ -136,6 +140,9 @@ namespace ml_lme
Settings.RootAngleChange -= this.OnRootAngleChange;
Settings.HeadAttachChange -= this.OnHeadAttachChange;
Settings.HeadOffsetChange -= this.OnHeadOffsetChange;
VRModeSwitchEvents.OnInitializeXR.RemoveListener(this.OnSwitchToVR);
VRModeSwitchEvents.OnDeinitializeXR.RemoveListener(this.OnSwitchToDesktop);
}
void Update()
@ -263,6 +270,18 @@ namespace ml_lme
OnHeadAttachChange(Settings.HeadAttach);
}
void OnSwitchToVR()
{
m_inVR = true;
OnHeadAttachChange(Settings.HeadAttach);
}
void OnSwitchToDesktop()
{
m_inVR = false;
OnHeadAttachChange(Settings.HeadAttach);
}
// Utils
static void OrientationAdjustment(ref Vector3 p_pos, ref Quaternion p_rot, Settings.LeapTrackingMode p_mode)
{
switch(p_mode)