Search Unity

Lock track type of TimelineAsset's subclass

Discussion in 'Timeline' started by 5argon, Oct 8, 2021.

  1. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I wonder if there is any attribute for me to paste on my subclass of TimelineAsset so only a certain kind of tracks are allowed in it? In my timeline asset meant for audio, then I want only AudioTrack in it, for example. It does not make sense that the + menu inside shows everything. (Though technically, playable graph is universal and always can be used together. Just for UX purpose that I want to show only subset of them.)
     
    Midiphony-panda likes this.
  2. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    We haven't built much customizability in the add track UI besides removing your own tracks from the menu, and we didn't really expect how people would subclass TimelineAsset. Though I really like the idea of purpose-built Timelines.

    I think there are two options:

    1- It looks like we're using
    [TrackClipType(typeof(TrackAsset))]
    on
    GroupTrack
    . Maybe you can subclass GroupTrack, and limit it to a specific TrackAsset Type. You could then use the + button or the context menu on the grouptrack instead of the main one. I haven't tried it, but it looks promising.

    2- Harder one: you can embed Timeline in your project and modify it to filter out tracks based on a custom attribute.
    The code that collects the tracks is fairly localized, and I can point you where to look.
     
    Last edited: Oct 8, 2021
    5argon likes this.
  3. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    Thank you! I will look into that.

    I would like to suggest one other customization point as well. It is the "Add {0} From {1}" menu that was exhaustively fetched from my assembly. I think it tries to be nice by seeing if a clip has an object field then it offer to pick an asset and even assign to it. It works with something like AudioPlayableAsset because it is missing exactly 1 object reference (AudioClip)

    But in my several custom clip type that requires multiple object assignments to get it working, it permutates everything but no choice is the right choice because each choice assign only 1 of 3 missing objects, I have to continue assign 2 or more missing objects anyway.. maybe a new attribute to put on the track type other than [TrackClipType] to customize this list would be really helpful!

    upload_2021-10-9_2-25-4.png
     
  4. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    What kind of things do you need to assign there?

    If these things are custom, I think you could use a common interface to filter out the acceptable types better than
    TrackClipType(typeof(Object))



    Hmmm... Actually I think I misread your question.
    I'm not sure how we could offer a better customization for this.

    If I had to fix it using the current paradigm, I would create intermediate configuration ScriptableObjects that contain all my necessary information then bind on that.