Timeline Parameters?
We're trying to use Timelines in a more dynamic way than is supported by retargeting just the outputs. ControlTrack
s, for instance have a ParentObject
parameter that I can't figure out how to set from script.
Would it make sense to add something like the Parameters
from Mecanim state machines to Timeline
s so the clips can use GenericBinding
s to refer to arbitrarily named input parameters? That'd be awesome.
Answer by seant_unity · Feb 01, 2018 at 12:22 PM
Here's an example of how to do set the parent object. Any scene references in a timeline asset, are stored inside the playableDirector in the scene.
public void SetControlTrackParent(PlayableDirector director, TimelineClip clip, GameObject go)
{
var controlTrackAsset = clip.asset as ControlPlayableAsset;
if (controlTrackAsset != null)
{
var propertyID = controlTrackAsset.sourceGameObject.exposedName;
director.SetReferenceValue(propertyID, go);
}
}
Thanks. Iterating over all the clips in the track is cumbersome, but it will work.
When to invoke this function?Before invoking director.Play()?
Yes, if it's already playing you will need to stop and restart.
Thanks.I mistook to pass a transform to the SetReferenceValue function before and it didn't work.