Hi, scratching my head here trying to get a ‘lifecycle’ for created clips on a timeline.
I want to be able to bind my clip to an entry in an external database, which means i need to know when the clip is created and destroyed. This following code seems to work, but only if it’s being edited on a gameobject with a director. If I select the timeline as an asset in the Project view, the createplayable event doesn’t seem to fire.
public class TriggerDialog : PlayableAsset {
private int instanceID = -1;
public override Playable CreatePlayable (PlayableGraph graph, GameObject owner) {
if (instanceID != GetInstanceID()) {
// the playable is created whenever the graph comes into memory, in edit mode as well
instanceID = GetInstanceID ();
Debug.Log ("being born.. my new id is "+ instanceID);
// create in the database here
}
// creating the specific behavior that actually runs on the timeline
TriggerDialogBehaviour b = new TriggerDialogBehaviour();
ScriptPlayable<TriggerDialogBehaviour> p = ScriptPlayable<TriggerDialogBehaviour>.Create(graph, b);
return p;
}
public void OnDestroy () {
Debug.Log ("Im dying, and my ID was " + id);
// remove from the database here
}
}
How can I know when a custom clip type is created and destroyed? Most of the methods/events seem to handle the creation and execution of the graph in playmode, rather than editor scripting.