Skip to content

Commit

Permalink
Fixed build error: Changed Application.onBeforeRender event to Render…
Browse files Browse the repository at this point in the history
…PipelineManager.beginContextRendering for URP support.
  • Loading branch information
toydev committed Nov 19, 2023
1 parent 3bb6684 commit 890fe13
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
9 changes: 6 additions & 3 deletions SteamVRLib_Valve.VR/SteamVR/Scripts/SteamVR_Behaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;

#if UNITY_2017_2_OR_NEWER
using UnityEngine.XR;
Expand Down Expand Up @@ -94,6 +95,7 @@ protected void Awake()
{
isPlaying = true;
xrDevice_deviceLoaded = (Il2CppSystem.Action<string>)XRDevice_deviceLoaded;
onBeforeRender = (Il2CppSystem.Action<ScriptableRenderContext, Il2CppSystem.Collections.Generic.List<Camera>>)OnBeforeRender;

if (initializeSteamVROnAwake && forcingInitialization == false)
InitializeSteamVR();
Expand Down Expand Up @@ -176,15 +178,16 @@ private void OnDestroy()
#if UNITY_2017_1_OR_NEWER
protected void OnEnable()
{
Application.onBeforeRender += OnBeforeRender;
RenderPipelineManager.beginContextRendering += onBeforeRender;
SteamVR_Events.System(EVREventType.VREvent_Quit).Listen(OnQuit);
}
protected void OnDisable()
{
Application.onBeforeRender -= OnBeforeRender;
RenderPipelineManager.beginContextRendering -= onBeforeRender;
SteamVR_Events.System(EVREventType.VREvent_Quit).Remove(OnQuit);
}
protected void OnBeforeRender()
private Il2CppSystem.Action<ScriptableRenderContext, Il2CppSystem.Collections.Generic.List<Camera>> onBeforeRender;
protected void OnBeforeRender(ScriptableRenderContext context, Il2CppSystem.Collections.Generic.List<Camera> cameras)
{
PreCull();
}
Expand Down
13 changes: 10 additions & 3 deletions SteamVRLib_Valve.VR/SteamVR/Scripts/SteamVR_Render.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

using UnityEngine;
using System.Collections;
using UnityEngine.Rendering;

namespace Valve.VR
{
Expand Down Expand Up @@ -304,6 +305,11 @@ private void OnRequestScreenshot(VREvent_t vrEvent)

private EVRScreenshotType[] screenshotTypes = new EVRScreenshotType[] { EVRScreenshotType.StereoPanorama };

private void Awake()
{
onBeforeRender = (Il2CppSystem.Action<ScriptableRenderContext, Il2CppSystem.Collections.Generic.List<Camera>>)OnBeforeRender;
}

private void OnEnable()
{
BepInEx.Unity.IL2CPP.Utils.MonoBehaviourExtensions.StartCoroutine(this, RenderLoop());
Expand All @@ -314,7 +320,7 @@ private void OnEnable()
SteamVR_ExternalCamera_LegacyManager.SubscribeToNewPoses();

#if UNITY_2017_1_OR_NEWER
Application.onBeforeRender += OnBeforeRender;
RenderPipelineManager.beginContextRendering += onBeforeRender;
#else
Camera.onPreCull += OnCameraPreCull;
#endif
Expand All @@ -338,7 +344,7 @@ private void OnDisable()
SteamVR_Events.System(EVREventType.VREvent_RequestScreenshot).Remove(OnRequestScreenshot);

#if UNITY_2017_1_OR_NEWER
Application.onBeforeRender -= OnBeforeRender;
RenderPipelineManager.beginContextRendering -= onBeforeRender;
#else
Camera.onPreCull -= OnCameraPreCull;
#endif
Expand All @@ -359,7 +365,8 @@ public void UpdatePoses()
}

#if UNITY_2017_1_OR_NEWER
void OnBeforeRender()
private Il2CppSystem.Action<ScriptableRenderContext, Il2CppSystem.Collections.Generic.List<Camera>> onBeforeRender;
protected void OnBeforeRender(ScriptableRenderContext context, Il2CppSystem.Collections.Generic.List<Camera> cameras)
{
if (SteamVR.active == false)
return;
Expand Down

0 comments on commit 890fe13

Please sign in to comment.