1
0
mirror of https://github.com/originalnicodr/CinematicUnityExplorer.git synced 2025-07-18 17:38:01 +08:00

Added new safeguards when adding and removing event handlers to the rendering pipeline. Also changed the "reset camera on new freecam sessions" option default value to true, as its more intuitive.
Some checks are pending
Build CinematicUnityExplorer / build_dotnet (push) Waiting to run
Build CinematicUnityExplorer / build_connector (push) Waiting to run

This commit is contained in:
originalnicodr
2025-02-23 20:27:50 -03:00
parent 9144f89e32
commit 2719c69753
2 changed files with 76 additions and 61 deletions

View File

@ -191,7 +191,7 @@ namespace UnityExplorer.Config
Reset_Camera_Transform = new("Reset Camera transform on freecam disable",
"Reset the camera position and rotation between freecam sessions, so the freecam always starts from the gameplay position and rotation.",
false);
true);
Arrow_Size = new("Visualizers arrows size",
"Cam Paths nodes and Lights Manager lights visualizers' arrow size (must be positive) (needs visualizer toggled to reflect changes).",

View File

@ -1068,6 +1068,9 @@ namespace UnityExplorer.UI.Panels
ExplorerCore.LogWarning($"Failed to listen to BeforeRender: {exception}");
}
#endif
try
{
// These doesn't exist for Unity <2017 nor when using HDRP
Type renderPipelineManagerType = ReflectionUtility.GetTypeByName("RenderPipelineManager");
if (renderPipelineManagerType != null){
@ -1104,6 +1107,11 @@ namespace UnityExplorer.UI.Panels
onBeforeRenderEvent.AddEventHandler(null, onBeforeRenderAction);
}
}
catch (Exception exception)
{
ExplorerCore.LogWarning($"Failed to add event handler to rendering pipeline: {exception}");
}
}
protected virtual void OnDisable()
{
@ -1117,9 +1125,11 @@ namespace UnityExplorer.UI.Panels
ExplorerCore.LogWarning($"Failed to unlisten from BeforeRender: {exception}");
}
#endif
try
{
// These doesn't exist for Unity <2017 nor when using HDRP
Type renderPipelineManagerType = ReflectionUtility.GetTypeByName("RenderPipelineManager");
if (renderPipelineManagerType != null){
EventInfo beginFrameRenderingEvent = renderPipelineManagerType.GetEvent("beginFrameRendering");
if (beginFrameRenderingEvent != null) {
@ -1154,6 +1164,11 @@ namespace UnityExplorer.UI.Panels
onBeforeRenderEvent.RemoveEventHandler(null, onBeforeRenderAction);
}
}
catch (Exception exception)
{
ExplorerCore.LogWarning($"Failed to remove event handler from rendering pipeline: {exception}");
}
}
private void OnBeforeEvent(object arg1, Camera[] arg2)
{