Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Is recreating the track a expected behaviour?

Discussion in 'Timeline' started by fegabe, Jun 9, 2020.

  1. fegabe

    fegabe

    Joined:
    Jan 3, 2015
    Posts:
    18
    Hello,

    I'm creating a custom track to make NPCs follow a path of points specified in a custom clip and I'm having an issue because I've discovered that when, in play mode, I change between different GameObjects in the hierarchy view and I go back to the timeline, it is recreated.

    My question is if it is an expected behavior in Timeline that the track and its clips can be recreated when the Timeline UI is recreated.

    I've created a simple project with the minimum code needed to create a custom track and a custom clip to help you understand the issue (I'm only adding the gif)

    Thanks!


     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    For clarity, the track and clip don't get recreated (they are assets). The Timeline Editor window, however, may cause the PlayableGraph (runtime representation of the timeline) to be rebuilt, which means your PlayableBehaviours will get destroyed and recreated.
     
  3. dukerustfield

    dukerustfield

    Joined:
    Dec 5, 2019
    Posts:
    33
    Seant, I'm following this for a similar concept. To be able to mute and unmute tracks. Which means we really have to yank them from the PlayableGraph to have any impact during runtime. How heavyweight is the process of rebuilding the graph? It seems a heinously bad thing to do, but since actual mute doesn't work during run, it's really the only way to do it. Thx.
     
  4. fegabe

    fegabe

    Joined:
    Jan 3, 2015
    Posts:
    18
    Thanks Seant, you were fast!

    Then how could I initialize a clip's behaviour? I was doing it when the clip (that inherits from PlayableAsset) was created but since it can be recreated there should be a better way right?

    Thanks again
     
  5. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    The clip can be initialized in your PlayableAsset.CreatePlayable override, or OnBehaviourPlay, or OnGraphStart. It depends what you mean by initialize. Any data the user can change should be on the Asset, (or a template of PlayableBehaviour), and copied to Behaviour when it is created.

    From a design perspective the PlayableBehaviour is an 'instance' of the clip - meaning, it can be destroyed/recreated as needed, or there can be multiple copies active at once (for example, two PlayableDirectors playing the same timeline with different bindings - each one will use the same assets, but have different instances).

    The editor does try to rebuild minimally, but it does happen.
     
    fegabe likes this.