Becasuse of some manual copies of PlayableDirector,now PlayableDirector Components in some Prefab have many unused bindings. Are there some apis to get all bindinds in PlayableDirector?
This may have changed in later versions I think. In Unity 2021.2.16 / Timeline 1.6.4 at least there’s a little minus sign at the very bottom-right of the Bindings field. Highlight the unused binding (or entire unused Timeline), and hit the minus to remove the ones not used.
It’s hard to delete the unused bindings…since it stored in a property named ‘m_SceneBindings’ which cannot be read/written directly.
A workaround to remove the unused bindings is to create a new Playable Director and copy the bindings from the old one.
Sample code:
private static void PlayableDirectorRebinding(PlayableDirector playableDirector)
{
if (playableDirector != null)
{
var timeline = playableDirector.playableAsset as TimelineAsset;
if (timeline != null)
{
var bindings = new Dictionary<Object, Object>();
foreach (var playableBinding in timeline.outputs)
{
bindings.Add(playableBinding.sourceObject, playableDirector.GetGenericBinding(playableBinding.sourceObject));
}
var timelineGameObject = playableDirector.gameObject;
GameObject.DestroyImmediate(playableDirector);
playableDirector = timelineGameObject.AddComponent<PlayableDirector>();
foreach (var entry in bindings)
{
playableDirector.SetGenericBinding(entry.Key, entry.Value);
}
}
}
}
Reference form here: Timeline Note--引用无关资源_timelineasset 复制问题_cai612781的博客-CSDN博客