Firstborn/Library/PackageCache/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Utils/PostProcessEffectRendererEx...

35 lines
1.1 KiB
C#
Raw Normal View History

2023-03-28 13:24:16 -04:00
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;
}
}
}