diff --git a/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs b/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs index c540dbb85be..251403878d6 100644 --- a/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs +++ b/com.unity.render-pipelines.core/Runtime/Textures/RTHandle.cs @@ -68,6 +68,10 @@ internal RTHandle(RTHandleSystem owner) /// RenderTexture representation of the RTHandle. public static implicit operator RenderTexture(RTHandle handle) { + // If RTHandle is null then conversion should give a null RenderTexture + if (handle == null) + return null; + Debug.Assert(handle.rt != null, "RTHandle was created using a regular Texture and is used as a RenderTexture"); return handle.rt; } @@ -79,6 +83,10 @@ public static implicit operator RenderTexture(RTHandle handle) /// Texture representation of the RTHandle. public static implicit operator Texture(RTHandle handle) { + // If RTHandle is null then conversion should give a null Texture + if (handle == null) + return null; + Debug.Assert(handle.m_ExternalTexture != null || handle.rt != null); return (handle.rt != null) ? handle.rt : handle.m_ExternalTexture; }