Search Unity

Custom tracks with multiple bindings

Discussion in 'Timeline' started by andybak, Jul 6, 2018.

  1. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    I want to animate several related things with one custom track.

    To give a simple example. say I want a single track to handle my scene "mood". It might need to affect a light and an image effect on the camera.

    Now - tracks can only have a single binding. I've tried putting references to the camera and the light directly on the clips and my code assumes that the same light and camera are on all clips on the track.

    For the most part this works but there are a couple of strange flaws. Properties don't update immediately upon edit - I think something needs to trigger the graph to be recreated or something similar. Plus it's a bit clunky.

    I'm guessing my properties are not updating due to the fact that they are not references in
    GatherProperties on the custom Track script. I'm not entirely sure to be honest.

    One workaround would be a proxy GameObject component that was bound to the track and passed on the values to the real camera and light. This is not ideal as it adds more clutter to the scene.

    Playables and custom tracks seem to lack more than the most cursory documentation for such a complex system and a lot of the examples are very specific. The best info I've found is by looking at other custom tracks but my case is slightly unique and I can't find anyone doing anything along the same lines.
     
  2. nikefootbag

    nikefootbag

    Joined:
    Jun 13, 2017
    Posts:
    28
    @andybak how did you go with this in the end? I'm trying to solve a similar issue and figured the proxy Gameobject component might be the only option. Keen to know if you were able to have multiple bindings on a single track tho?
     
    Midiphony-panda likes this.
  3. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    I can't remember now. I think I just learned to live with the problems of using clip bindings.
     
  4. Cameron_SM

    Cameron_SM

    Joined:
    Jun 1, 2009
    Posts:
    915
    Are you using PropertyReference<T> with your custom clips? The timeline inspector uses those as a kind of contract to bind the reference when the graph is compiled at runtime.

    But for the OPs specific case you might just want to completely decouple the mood state from the instances that need to know about it to change values and have a track binding to a monobehaviour that broadcasts an event of the current mood and objects in your scene subscribe to that monobehaviour.

    You could then have ColorMoodListener that has an exposed UnityEvent<Color> and a list of {Mood; Color} mappings that passes that Color through to the unity event which is driving a light components Color. Can even have the event and listener use a list of moods with weights so you get blending from the timeline or just have states be discreet and do some blending on the listener.
     
    Last edited: Sep 16, 2021
    mandisaw and jeromeWork like this.
  5. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    I don't have easy access to the project right now as I haven't touched it for over 2 years. I will probably revisit this topic when I next do some timeline stuff but my head is elsewhere right now.

    Thanks tons for the input though. I'm bookmarking this.