Firstborn/Library/PackageCache/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Utils/PostProcessEffectRendererEx...
Schaken-Mods b486678290 Library -Artifacts
Library -Artifacts
2023-03-28 12:24:16 -05:00

35 lines
1.1 KiB
C#

using System;
namespace UnityEngine.Rendering.PostProcessing
{
static class PostProcessEffectRendererExtensions
{
/// <summary>
/// Render with a try catch for all exception.
///
/// If an exception occurs during the <see cref="PostProcessEffectRenderer.Render"/> call, it will be logged
/// and returned.
///
/// Use this method instead of <see cref="PostProcessEffectRenderer.Render"/> in critical contexts
/// to avoid entering the exception flow.
/// </summary>
/// <param name="self">The renderer to render.</param>
/// <param name="context">A context object</param>
/// <returns></returns>
public static Exception RenderOrLog(this PostProcessEffectRenderer self, PostProcessRenderContext context)
{
try
{
self.Render(context);
}
catch (Exception e)
{
Debug.LogException(e);
return e;
}
return null;
}
}
}