Problem
RenderTargetStrategy is a MonoBehaviour, so it can't be referenced across prefabs in the inspector. This makes sharing a PooledRenderTargetStrategy between panels in different prefabs awkward — you end up needing a scene singleton and a companion component to wire things up at runtime.
Suggestion
A thin RenderTargetStrategyAsset : ScriptableObject that holds pool configuration and manages the lifetime of the underlying runtime component. RivePanel would accept one alongside the existing RenderTargetStrategy field.
[CreateAssetMenu(...)]
public class PooledRenderTargetStrategyAsset : RenderTargetStrategyAsset
{
[SerializeField] private Vector2Int m_pooledTextureSize;
[SerializeField] private int m_initialPoolSize;
[SerializeField] private int m_maxPoolSize;
private PooledRenderTargetStrategy m_runtimeInstance;
public override RenderTargetStrategy GetOrCreateStrategy(GameObject host)
{
if (m_runtimeInstance != null) return m_runtimeInstance;
var strategy = host.AddComponent<PooledRenderTargetStrategy>();
strategy.Configure(m_pooledTextureSize, m_initialPoolSize, m_maxPoolSize, ...);
m_runtimeInstance = strategy;
return strategy;
}
}
The ScriptableObject stays thin — just config and a factory. The MonoBehaviour still does the actual work, so nothing about LateUpdate batching or render pipeline registration needs to change.
Problem
RenderTargetStrategyis aMonoBehaviour, so it can't be referenced across prefabs in the inspector. This makes sharing aPooledRenderTargetStrategybetween panels in different prefabs awkward — you end up needing a scene singleton and a companion component to wire things up at runtime.Suggestion
A thin
RenderTargetStrategyAsset : ScriptableObjectthat holds pool configuration and manages the lifetime of the underlying runtime component.RivePanelwould accept one alongside the existingRenderTargetStrategyfield.The
ScriptableObjectstays thin — just config and a factory. TheMonoBehaviourstill does the actual work, so nothing about LateUpdate batching or render pipeline registration needs to change.