using System;
using UnityEngine.Scripting.APIUpdating;
namespace UnityEngine.Rendering.Universal
{
///
/// You can add a ScriptableRendererFeature to the ScriptableRenderer. Use this scriptable renderer feature to inject render passes into the renderer.
///
///
///
[ExcludeFromPreset]
public abstract class ScriptableRendererFeature : ScriptableObject, IDisposable
{
[SerializeField, HideInInspector] private bool m_Active = true;
///
/// Returns the state of the ScriptableRenderFeature (true: the feature is active, false: the feature is inactive). Use the method ScriptableRenderFeature.SetActive to change the value of this variable.
///
public bool isActive => m_Active;
///
/// Initializes this feature's resources. This is called every time serialization happens.
///
public abstract void Create();
///
/// Callback before cull happens in renderer.
///
/// Renderer of callback.
/// CameraData contains all relevant render target information for the camera.
public virtual void OnCameraPreCull(ScriptableRenderer renderer, in CameraData cameraData) { }
///
/// Injects one or multiple ScriptableRenderPass in the renderer.
///
/// Renderer used for adding render passes.
/// Rendering state. Use this to setup render passes.
public abstract void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData);
void OnEnable()
{
Create();
}
void OnValidate()
{
Create();
}
///
/// Override this method and return true if the feature should use the Native RenderPass API
///
internal virtual bool SupportsNativeRenderPass()
{
return false;
}
///
/// Sets the state of ScriptableRenderFeature (true: the feature is active, false: the feature is inactive).
/// If the feature is active, it is added to the renderer it is attached to, otherwise the feature is skipped while rendering.
///
/// The true value activates the ScriptableRenderFeature and the false value deactivates it.
public void SetActive(bool active)
{
m_Active = active;
}
///
/// Disposable pattern implementation.
///
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
}
}
}