Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Multiple TrackClipType

Discussion in 'Timeline' started by R40ul_OSG, Apr 27, 2017.

  1. R40ul_OSG

    R40ul_OSG

    Joined:
    Sep 2, 2016
    Posts:
    43
    I've created a custom track to hold all the actions my characters will perform in timeline. I've made all these actions inherit from an absctract class called CharacterPlayable which itself inherits from ScriptPlayable
    I'd like to be able to add only these actions in my CharacterTrack, but I can't find a way to do this.
    Here are some snippets of my code :

    Code (CSharp):
    1. [TrackBindingType(typeof(Character))]
    2. [TrackClipType(typeof(CharacterPlayableAsset))] //Also tried with CharacterPlayable
    3.  
    4. public class CharacterTrack : PlayableTrack {
    5.  
    6. }
    Code (CSharp):
    1. [System.Serializable]
    2. public class LookAt : CharacterPlayableAsset {
    3.  
    4.     public ExposedReference<GameObject> Agent;
    5.     public ExposedReference<Transform> Target;
    6.  
    7.     public override PlayableHandle CreatePlayable (PlayableGraph graph, GameObject owner)
    8.     {
    9.         var handle = graph.CreateScriptPlayable<LookAtPlayable> ();
    10.         handle.GetObject<LookAtPlayable> ()._agent = Agent.Resolve (graph.resolver);
    11.         handle.GetObject<LookAtPlayable> ()._target = Target.Resolve (graph.resolver);
    12.         return handle;
    13.     }
    14. }
    Code (CSharp):
    1. [System.Serializable]
    2. public class LookAtPlayable : CharacterPlayable {
    3.  
    4.     public Transform _target;
    5.     public GameObject _agent;
    6.  
    7.     public override void ProcessFrame (FrameData info, object playerData)
    8.     {
    9.         _agent.transform.LookAt (_target);
    10.     }
    11.  
    12. }
    I also have an other class build on the same method as LookAt that also inherits from CharacterPlayableAsset.
    When I right clic on my CharacterTrack in Timeline, I expect to see both methods I've created, but I only get the option to add a CharacterPlayableAsset (which is abstract), and I get the following error when I do so :
    I have also tried to add one "TrackClipType" per class I want to be able to select, but it only keeps the last one.

    How can I solve this?
     
  2. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    427
    Did you ever figure this out? I also need the ability to specify which sub classes can go into a track.
     
  3. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    427
    I'm starting to think this is a bug ... the documentation uses plural for "Scriptplayables" and "clips", which leads one to assume you should be able to add multiple trackcliptypes using this. If this is a bug, can we get a confirmation on this, so we can leave it as is in the code for now and assumably have it fixed in a coming update?

    From the docs: "Specifies the type of PlayableAsset or ScriptPlayables that this track can create clips representing.

    This is required for custom track assets to specify the type of clips to create."
     
  4. Meatgrind

    Meatgrind

    Joined:
    Jul 12, 2012
    Posts:
    45
    Having similar problems. I'm trying to add multiple Clip types to the same Track in very much the same idea.

    I don't think it's a bug - neither Editor-internal Timeline Tracks nor the DefaultPlayable Track examples show a single Track that would have this kind of behaviour that it would take multiple Clip types (Animation and Audio tracks have multiple context click menuitems, but they are only shortcuts to select a different source for the setup of single-type the Audio/Animation type Playables for their respective tracks).

    For now I'm planning to make some kind of Clip class to hold all kinds of parameters and then inheriting that class just to have different PropertyDrawers that expose only desired fields to the Inspector - I'd much rather just inherit the base class used as the TrackClipType and setup the parameters neatly per child class, but I suspect Unity's serialization would lose sight of the data stored in child class type if the Clip stores a serialized field that is the type of the base class.
     
  5. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,035
    This appears to be a bug in the UI. The drop down menu is only picking up the first clip type specified.

    I've logged a bug for this, hopefully it will be fixed soon.
     
  6. blackbookuser

    blackbookuser

    Joined:
    Aug 29, 2017
    Posts:
    2
    What is the timeline for this fix? We are running into the same problem now in trying to extend the timeline in order to reduce boilerplate stuff.
     
    DGordon likes this.
  7. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    427
    Seconding the request to know about its status, or an understanding how how to find the bug that was apparently logged?

    Very curious what way we're supposed to go about tracking this, thanks!
     
  8. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,035
    Yes, it is working in (at least) 2019.2. You can specify multiple TrackClipType attributes, or use a base class, or use an interface.
     
    blackbookuser and DGordon like this.