using System; namespace XCEngine { public abstract class ScriptableRendererData : Object { private ScriptableRendererFeature[] m_rendererFeatures; protected ScriptableRendererData() { } internal ScriptableRenderer CreateRendererInstance() { return CreateRenderer(); } internal ScriptableRendererFeature[] CreateRendererFeaturesInstance() { return GetRendererFeatures(); } internal void ConfigureCameraRenderRequestInstance( ScriptableRenderPipelineCameraRequestContext context) { ConfigureCameraRenderRequest(context); ScriptableRendererFeature[] rendererFeatures = GetRendererFeatures(); for (int i = 0; i < rendererFeatures.Length; ++i) { ScriptableRendererFeature rendererFeature = rendererFeatures[i]; if (rendererFeature == null || !rendererFeature.isActive) { continue; } rendererFeature.ConfigureCameraRenderRequest( context); } } internal void ConfigureCameraFramePlanInstance( ScriptableRenderPipelinePlanningContext context) { ConfigureCameraFramePlan(context); ScriptableRendererFeature[] rendererFeatures = GetRendererFeatures(); for (int i = 0; i < rendererFeatures.Length; ++i) { ScriptableRendererFeature rendererFeature = rendererFeatures[i]; if (rendererFeature == null || !rendererFeature.isActive) { continue; } rendererFeature.ConfigureCameraFramePlan( context); } } protected virtual ScriptableRenderer CreateRenderer() { return null; } protected virtual void ConfigureCameraRenderRequest( ScriptableRenderPipelineCameraRequestContext context) { } protected virtual void ConfigureCameraFramePlan( ScriptableRenderPipelinePlanningContext context) { } protected virtual ScriptableRendererFeature[] CreateRendererFeatures() { return Array.Empty(); } private ScriptableRendererFeature[] GetRendererFeatures() { if (m_rendererFeatures == null) { m_rendererFeatures = CreateRendererFeatures() ?? Array.Empty(); } return m_rendererFeatures; } } }