委托,可在 RenderPipelineManager.currentPipeline 被处置之前用来调用自定义代码。
每当你切换 GraphicsSettings.currentRenderPipeline 或 QualitySettings.renderPipeline 时,Unity 都会在实例化新的 RenderPipeline
之前处置当前的 RenderPipeline
。你可以订阅此事件来获知当前 RenderPipeline
何时会被处置。要访问当前正在处置的 RenderPipeline
对象,你可以依赖 RenderPipelineManager.currentPipeline。
using UnityEngine; using UnityEngine.Rendering;
public class CurrentRenderPipelineDisposedExample : MonoBehaviour { void Start() { RenderPipelineManager.activeRenderPipelineDisposed += RenderPipelineManager_activeRenderPipelineDisposed; }
private void OnDestroy() { RenderPipelineManager.activeRenderPipelineDisposed -= RenderPipelineManager_activeRenderPipelineDisposed; }
private void RenderPipelineManager_activeRenderPipelineDisposed() { Debug.Log($"Render Pipeline {RenderPipelineManager.currentPipeline.GetType().Name} is disposing."); } }