in RealityMaterialExplorer/Assets/Oculus/VR/Scripts/OVRManager.cs [1613:1933]
private void Update()
{
//Only if we're using the XR SDK do we have to check if OVRManager isn't yet initialized, and init it.
//If we're on legacy, we know initialization occurred properly in Awake()
#if USING_XR_SDK
if (!OVRManagerinitialized)
{
XRDisplaySubsystem currentDisplaySubsystem = GetCurrentDisplaySubsystem();
XRDisplaySubsystemDescriptor currentDisplaySubsystemDescriptor = GetCurrentDisplaySubsystemDescriptor();
if (currentDisplaySubsystem == null || currentDisplaySubsystemDescriptor == null || !OVRPlugin.initialized)
return;
//If we're using the XR SDK and the display subsystem is present, and OVRPlugin is initialized, we can init OVRManager
InitOVRManager();
}
#endif
#if UNITY_EDITOR
if (_scriptsReloaded)
{
_scriptsReloaded = false;
instance = this;
Initialize();
}
#endif
SetCurrentXRDevice();
if (OVRPlugin.shouldQuit)
{
Debug.Log("[OVRManager] OVRPlugin.shouldQuit detected");
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || OVR_ANDROID_MRC
StaticShutdownMixedRealityCapture(instance);
#endif
Application.Quit();
}
if (AllowRecenter && OVRPlugin.shouldRecenter)
{
OVRManager.display.RecenterPose();
}
if (trackingOriginType != _trackingOriginType)
trackingOriginType = _trackingOriginType;
tracker.isEnabled = usePositionTracking;
OVRPlugin.rotation = useRotationTracking;
OVRPlugin.useIPDInPositionTracking = useIPDInPositionTracking;
// Dispatch HMD events.
isHmdPresent = OVRNodeStateProperties.IsHmdPresent();
if (useRecommendedMSAALevel && QualitySettings.antiAliasing != display.recommendedMSAALevel)
{
Debug.Log("The current MSAA level is " + QualitySettings.antiAliasing +
", but the recommended MSAA level is " + display.recommendedMSAALevel +
". Switching to the recommended level.");
QualitySettings.antiAliasing = display.recommendedMSAALevel;
}
if (monoscopic != _monoscopic)
{
monoscopic = _monoscopic;
}
if (headPoseRelativeOffsetRotation != _headPoseRelativeOffsetRotation)
{
headPoseRelativeOffsetRotation = _headPoseRelativeOffsetRotation;
}
if (headPoseRelativeOffsetTranslation != _headPoseRelativeOffsetTranslation)
{
headPoseRelativeOffsetTranslation = _headPoseRelativeOffsetTranslation;
}
if (_wasHmdPresent && !isHmdPresent)
{
try
{
Debug.Log("[OVRManager] HMDLost event");
if (HMDLost != null)
HMDLost();
}
catch (Exception e)
{
Debug.LogError("Caught Exception: " + e);
}
}
if (!_wasHmdPresent && isHmdPresent)
{
try
{
Debug.Log("[OVRManager] HMDAcquired event");
if (HMDAcquired != null)
HMDAcquired();
}
catch (Exception e)
{
Debug.LogError("Caught Exception: " + e);
}
}
_wasHmdPresent = isHmdPresent;
// Dispatch HMD mounted events.
isUserPresent = OVRPlugin.userPresent;
if (_wasUserPresent && !isUserPresent)
{
try
{
Debug.Log("[OVRManager] HMDUnmounted event");
if (HMDUnmounted != null)
HMDUnmounted();
}
catch (Exception e)
{
Debug.LogError("Caught Exception: " + e);
}
}
if (!_wasUserPresent && isUserPresent)
{
try
{
Debug.Log("[OVRManager] HMDMounted event");
if (HMDMounted != null)
HMDMounted();
}
catch (Exception e)
{
Debug.LogError("Caught Exception: " + e);
}
}
_wasUserPresent = isUserPresent;
// Dispatch VR Focus events.
hasVrFocus = OVRPlugin.hasVrFocus;
if (_hadVrFocus && !hasVrFocus)
{
try
{
Debug.Log("[OVRManager] VrFocusLost event");
if (VrFocusLost != null)
VrFocusLost();
}
catch (Exception e)
{
Debug.LogError("Caught Exception: " + e);
}
}
if (!_hadVrFocus && hasVrFocus)
{
try
{
Debug.Log("[OVRManager] VrFocusAcquired event");
if (VrFocusAcquired != null)
VrFocusAcquired();
}
catch (Exception e)
{
Debug.LogError("Caught Exception: " + e);
}
}
_hadVrFocus = hasVrFocus;
// Dispatch VR Input events.
bool hasInputFocus = OVRPlugin.hasInputFocus;
if (_hadInputFocus && !hasInputFocus)
{
try
{
Debug.Log("[OVRManager] InputFocusLost event");
if (InputFocusLost != null)
InputFocusLost();
}
catch (Exception e)
{
Debug.LogError("Caught Exception: " + e);
}
}
if (!_hadInputFocus && hasInputFocus)
{
try
{
Debug.Log("[OVRManager] InputFocusAcquired event");
if (InputFocusAcquired != null)
InputFocusAcquired();
}
catch (Exception e)
{
Debug.LogError("Caught Exception: " + e);
}
}
_hadInputFocus = hasInputFocus;
// Changing effective rendering resolution dynamically according performance
#if (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN)
if (enableAdaptiveResolution)
{
if (Settings.eyeTextureResolutionScale < maxRenderScale)
{
// Allocate renderScale to max to avoid re-allocation
Settings.eyeTextureResolutionScale = maxRenderScale;
}
else
{
// Adjusting maxRenderScale in case app started with a larger renderScale value
maxRenderScale = Mathf.Max(maxRenderScale, Settings.eyeTextureResolutionScale);
}
minRenderScale = Mathf.Min(minRenderScale, maxRenderScale);
float minViewportScale = minRenderScale / Settings.eyeTextureResolutionScale;
float recommendedViewportScale = Mathf.Clamp(Mathf.Sqrt(OVRPlugin.GetAdaptiveGPUPerformanceScale()) * Settings.eyeTextureResolutionScale * Settings.renderViewportScale, 0.5f, 2.0f);
recommendedViewportScale /= Settings.eyeTextureResolutionScale;
recommendedViewportScale = Mathf.Clamp(recommendedViewportScale, minViewportScale, 1.0f);
Settings.renderViewportScale = recommendedViewportScale;
}
#endif
// Dispatch Audio Device events.
string audioOutId = OVRPlugin.audioOutId;
if (!prevAudioOutIdIsCached)
{
prevAudioOutId = audioOutId;
prevAudioOutIdIsCached = true;
}
else if (audioOutId != prevAudioOutId)
{
try
{
Debug.Log("[OVRManager] AudioOutChanged event");
if (AudioOutChanged != null)
AudioOutChanged();
}
catch (Exception e)
{
Debug.LogError("Caught Exception: " + e);
}
prevAudioOutId = audioOutId;
}
string audioInId = OVRPlugin.audioInId;
if (!prevAudioInIdIsCached)
{
prevAudioInId = audioInId;
prevAudioInIdIsCached = true;
}
else if (audioInId != prevAudioInId)
{
try
{
Debug.Log("[OVRManager] AudioInChanged event");
if (AudioInChanged != null)
AudioInChanged();
}
catch (Exception e)
{
Debug.LogError("Caught Exception: " + e);
}
prevAudioInId = audioInId;
}
// Dispatch tracking events.
if (wasPositionTracked && !tracker.isPositionTracked)
{
try
{
Debug.Log("[OVRManager] TrackingLost event");
if (TrackingLost != null)
TrackingLost();
}
catch (Exception e)
{
Debug.LogError("Caught Exception: " + e);
}
}
if (!wasPositionTracked && tracker.isPositionTracked)
{
try
{
Debug.Log("[OVRManager] TrackingAcquired event");
if (TrackingAcquired != null)
TrackingAcquired();
}
catch (Exception e)
{
Debug.LogError("Caught Exception: " + e);
}
}
wasPositionTracked = tracker.isPositionTracked;
display.Update();
OVRInput.Update();
UpdateHMDEvents();
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || OVR_ANDROID_MRC
StaticUpdateMixedRealityCapture(this, gameObject, trackingOriginType);
#endif
}