Search Unity

Extending GroupTrack

Discussion in 'Timeline' started by panta, Aug 1, 2018.

  1. panta

    panta

    Joined:
    Aug 10, 2012
    Posts:
    71
    I was surprised to find that this didn't work:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using System.Linq;
    4. using UnityEngine;
    5. using UnityEngine.Playables;
    6. using UnityEngine.Timeline;
    7.  
    8. /// <summary>
    9. /// Special <see cref="GroupTrack"/> that mutes all of its children
    10. /// when you enter play mode.
    11. /// Useful for edit-time tracks that mimic gameplay (such as moving/knockback the character or playing enemy hit reacts)
    12. /// that you don't want to impact the final game.
    13. /// </summary>
    14. public class EditOnlyGroupTrack : GroupTrack
    15. {
    16.     public override Playable CreateTrackMixer(PlayableGraph graph, GameObject go, int inputCount)
    17.     {
    18.         this.GetChildTracks().ToList().ForEach(t => t.muted = Application.isPlaying);
    19.  
    20.         return base.CreateTrackMixer(graph, go, inputCount);
    21.     }
    22. }
    23.  
    The result was a rather sad looking non-group track:
    upload_2018-7-31_18-43-12.png

    Is there a reason we can't extend GroupTrack to make our own groups with custom behaviour?

    Thank you!
     
  2. panta

    panta

    Joined:
    Aug 10, 2012
    Posts:
    71
  3. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Group tracks are excluded from compilation of the PlayableGraph. They exist simply for organization purposes. We should have sealed the class. None of the compilation methods get called on them.

    And the custom track drawer (which isn't public because it is slated for change) doesn't apply to derived classes.
     
    panta likes this.
  4. panta

    panta

    Joined:
    Aug 10, 2012
    Posts:
    71
    Ok thank you for the confirmation.

    It would be helpful to have a way to run scripts over all of the tracks in a group. Is there any plans to allow something like that?
     
  5. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Not that exact request, but giving more access to the customize/extend the Timeline editor in general is planned. Also, we have plans to improve group tracks, and can keep your use case in mind.
     
    panta likes this.
  6. panta

    panta

    Joined:
    Aug 10, 2012
    Posts:
    71
    Thank you! The idea is basically that we have certain groups on our timeline that are there exclusively for the artist to imitate some of the effects of gameplay, like knockback or projectiles spawning, while they are iterating on VFX in edit mode.

    I have a workaround where i mute everything in a GroupTrack with a special name when I enter playmode, but it's not too elegant.
    Code (CSharp):
    1.  timelineAsset.GetTracks<GroupTrack>().Where(t => t.name.Contains(MUTE)).ToList().ForEach(g => g.GetChildTracks().ToList().ForEach(t => t.muted = true));
    2.  
    3. public static IEnumerable<T> GetTracks<T>(this TimelineAsset timelineAsset)
    4.         where T : TrackAsset
    5.     {
    6.         return timelineAsset?.outputs
    7.             .Select(o => o.sourceObject)
    8.             .OfType<T>();
    9.     }
    10.  
    BTW, I'm working at a studio that's doing a fairly high profile game/TV show combination and we are very much open to partnership with Unity to showcase features/the platform's potential. Most of our team (except for me) either came from studios with custom engines or Unreal, so it's been interesting to compare Unity's timeline to the features offered by Unreal's Matinee, etc.

    Let me know if there's a channel I can reach out to to explore this possibility!

    Thank you