I have a system where I Instantiate a prefab with a timeline in it. This timeline uses mostly objects within its own prefab but uses a signal receiver in the scene along with a couple other elements.
How would I go about identifying the missing binds and re-binding them before playing the director? I found some very old posts from 2017 about rebinding but that method doesn’t seem to work anymore and I’m looking to do the reverse where I check for missing bindings and replace them.
After some digging with a variant of things posted on the old thread I found; I managed to get a (mildly hacky) work around to re-bind missing objects in a timeline prefab.
I have a local class in my scene that contains an array of generic Objects and another array of the desired track names that I know will be missing bindings. It also has a unique “bind pack ID” which I use in editor to specify which director assets I am going to need. I will clean this up and make its own class for my own usage but here is what works currently in replacing missing bindings if it aids anyone else as a starting point at least.
public string bindPackID;
public Object[] localAssets;
public string[] localTrackNames;
void Start()
{
//Get our Objects to replace missing bindings for a specific director
localAssets = AnimationEventHandler.Ins.GetBidnigns(bindPackID);
//Get the corresponding track names for missing bindings for the same director
localTrackNames = AnimationEventHandler.Ins.GetBindingTrackNames(bindPackID);
for (int i = 0; i < localAssets.Length; i++)
{
//Step through each track and see if their name matches our missing track names
foreach (var PlayableAssetOutput in director.playableAsset.outputs)
{
if (PlayableAssetOutput.streamName == localTrackNames[i])
{
//replace missing bind with corresponding object
director.SetGenericBinding(PlayableAssetOutput.sourceObject, localAssets[i]);
}
}
}
}
I’m including a picture of the editor window even though Unity is being Unity with it’s UI drawing issues. But you can see I have two arrays and the track names corresponds with the elements of the same array index. I grab this list using the director ID from a script that sits on the prefab playable director game object.
1 Like