using System; using System.Collections.Generic; using UnityEngine; namespace UnityEditor.Recorder { /// /// A class to back up the RenderTextures onto a stack /// class RenderTextureActiveGuard : IDisposable { static Stack backups = new(); /// /// Push the RenderTextures to a stack /// /// public RenderTextureActiveGuard(RenderTexture tex) { backups.Push(RenderTexture.active); RenderTexture.active = tex; } /// /// Pop the top RenderTexture from the stack and set it active /// public void Dispose() { var tex = backups.Pop(); RenderTexture.active = tex; } } }