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.
This commit is contained in:
@ -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).",
|
||||
|
@ -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)
|
||||
{
|
||||
|
Reference in New Issue
Block a user