Search Unity

ControlTrack for pooled objects

Discussion in 'Timeline' started by olejuer, Jul 30, 2020.

  1. olejuer

    olejuer

    Joined:
    Dec 1, 2014
    Posts:
    211
    Hi,

    I am using timeline for Player skills and actions and ControlTracks to create and control the respective effects. This works really great, but the control track will instantiate the effects from prefabs every time. For performance reasons, I would rather use pooled objects for which I have built a utility. So my question is how I would go about using a ControlPlayableAsset to control an object that I create with custom code.
    I would like to use the preview functionality in edit mode so I can time the effect properly with the rest of the timeline.
    Something like an extension of ControlPlayableAsset that accepts some kind of object provider would be perfect.

    Any suggestion is welcome! Thanks
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    The simplest option is to use Prefab instances in the scene, instead of prefabs. That doesn't use pooling, but the instances can be initially disabled in scene and reused between clips.

    Otherwise you would need to your own ControlTrack & ControlPlayableAsset class - or make timeline a local package and modify the existing one.

    Control Playable Assets use multiple playable behaviours - one to control prefab instances, another to simulate particles, another to control subtimelines, etc..

    This is all set up in the CreatePlayable override. As a minimum, you would need to replace the PrefabControlPlayable (which does the instancing) with a PlayableBehaviour that does pooling instead.

    Or just change the PrefabControlPlayable to use pools if available. I believe the control track is the only built-in track that uses it.
     
    olejuer likes this.