Search Unity

Why “postExtrapolationMode” property of TimelineClip is Read Only? How can I modfiy it in runtime?

Discussion in 'Animation' started by MaydayWorks, Sep 12, 2018.

  1. MaydayWorks

    MaydayWorks

    Joined:
    Aug 18, 2014
    Posts:
    6
    Hi,I want to generate a Timeline in runtime by creating a AnimationTrack and adding TimelineClips to it. All added AnimationClips will play and stopped in the final frame, while I want them to Loop forever.
    I tried to add a PlayableDirector and set the generated Timeline as its playable asset, then edit the TimelineClip which should extrapolation in Loop mode in inspector, and it works. But using codes, I found the “postExtrapolationMode” property of TimelineClip is Read Only, which leads to no way to set the clip extrapolation in Loop.
    Also I tried using reflection methods the change the property like this:
    Code (CSharp):
    1. typeof(TimelineClip).GetProperty("postExtrapolationMode").SetValue(animClip, TimelineClip.ClipExtrapolation.Loop, null);
    It seems to be work. I wonder is it a safe way to do so? and what is the offical way the change the code created TimelineClip's ExtrapolationMode?
    Thanks