Search Unity

Editing variables in behaviours in play mode

Discussion in 'Timeline' started by arvzg, Dec 19, 2018.

  1. arvzg

    arvzg

    Joined:
    Jun 28, 2009
    Posts:
    619
    For technical reasons, we have some need for editing our timelines in play mode.

    I've noticed that when changing the values of variables inside my PlayableBehaviours, the changes are not reflected when you rewind the timeline and play the clip again

    However if you let the timeline play until completion all the way to the end and play again, then those changes get reflected.

    This is most likely due to the fact that timeline clones my PlayableBehaviour (using the Template) so the values I'm changing are of the Template, not the actual behaviour that's in the graph.

    How do you go about solving this?
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    You need to change the values of the instance that is playing. CreatePlayable creates an instance of the template - you can save a reference to that and update it's values (or copy them from the template as needed).

    Alternately you can traverse the playable graph and find the particular playable (& playablebehaviour) you want to change, but saving it during compile is probably a lot easier.
     
    arvzg likes this.