Search Unity

Get animator from Animation Track in script

Discussion in 'Timeline' started by Antoine_OSG, Aug 3, 2017.

  1. Antoine_OSG

    Antoine_OSG

    Joined:
    Sep 2, 2016
    Posts:
    43
    I've created an animation track in my timeline, and now, I'd like to be able to get the animator I've linked to that track (the one you setup in the timeline window, in the header part of the track) in script. (if you look at the screenshot below, it's a script in CinematicDialogTrack that tries to access the animator in its group)

    I've checked all parameters and functions of TrackAsset and AnimationTrack, but I can't find anything suitable.
    I can't do a GetGenericBindings on my timeline as I have several tracks of the same type referencing different Animators.
    Can anyone help with this?
     
    Last edited: Aug 3, 2017
  2. AndrewKaninchen

    AndrewKaninchen

    Joined:
    Oct 30, 2016
    Posts:
    149
    You can try and get the Group Track the Cinematic Dialog Track belongs to and check for it's children to find the Animation Track; then you can get the GenericBinding of the Animation Track by passing it to the director.GetGenericBinding() method.

    With that you'll have this Character GameObject you set, and then a GetComponent<Animator> gets what you want.

    If the textual explanation isn't enough I can type some code to explain it better. I did something very similar here:
    https://forum.unity3d.com/threads/a...-via-the-timeline-editor.482834/#post-3151541
     
    thierry_unity and julienb like this.
  3. Antoine_OSG

    Antoine_OSG

    Joined:
    Sep 2, 2016
    Posts:
    43
    Thanks, I'll try something like that !