rive-app / rive-app/rive-unity

Allow `RenderTargetStrategy` to be shared across prefabs via ScriptableObject?

Open
#146 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
205
Forks
22
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing RenderTargetStrategy, PooledRenderTargetStrategy, and RivePanel implementations, then compare their lifecycle and inspector behavior with the proposed ScriptableObject asset. Done means a thin asset can share pooled configuration across prefabs while creating and managing the runtime strategy without changing LateUpdate batching or render pipeline registration.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, unity
Domain
game-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.