Hi, I am writing my custom playable track for timeline, and I’m stuck with exposed references thing.
I get the idea from the example custom tracks available online, how to connect one variable in PlayableBehaviour script with exposed reference in Clip script (PlayableAsset, ITimelineClipAsset) in CreatePlayable method.
[Serializable]
public class MyCustomBehaviour : PlayableBehaviour
{
public Transform myTransform;
}
[Serializable]
public class MyCustomClip : PlayableAsset, ITimelineClipAsset
{
public MyCustomBehaviour data = new MyCustomBehaviour();
public ExposedReference<Transform> exposedTransform;
public ClipCaps clipCaps
{
get { return ClipCaps.None; }
}
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
{
var playable = ScriptPlayable<MyCustomBehaviour>.Create(graph, data);
MyCustomBehaviour clone = playable.GetBehaviour();
clone.myTransform = exposedTransform.Resolve(graph.GetResolver());
return playable;
}
}
But, how to expose variable that is inside complex data structure, like this:
[Serializable]
public class MyCustomBehaviour : PlayableBehaviour
{
[Serializable]
public class MyCustomClass
{
//How to expose this variable?
public Transform myTransform;
}
public List<MyCustomClass> myCustomClassesList = new List<MyCustomClass>();
}
I have the same problem. I need a list of exposed references that is shown in the inspector but it does not work. For example, in the PlayableAsset I made I have a public variable of type List<ExposedReference> which I expected to be shown like any other list in the inspector, but it doesn’t. It just doesn’t want to get serialized as soon as it’s in a list. I tried to look into drawing a custom inspector for lists of exposed references but it became a bit complicated in the fact that it involved ExposedReference… I hope someone who know how to fix this. This is a big problem for the asset I’m currently working on.
I use wrapper for ExposedReference and then make array of wrappers as workaround
[Serializable]
public class ExposedReferenceHolder<T> where T : Object
{
public ExposedReference<T> ExposedReference;
}
[Serializable]
public class ExposedCollider : ExposedReferenceHolder<Collider>
{
}
[Serializable]
public class ColliderArrayBehaviour : PlayableBehaviour
{
public ExposedCollider[] TrackingObjects;
}
Yeah so I’ve basically wasted the last two days trying to come up with workarounds for this. The desire to use arrays in Timeline clips isn’t something that should be considered unusual or esoteric. I realize that this is mainly due to the serialization system but it really should be addressed and made to work out of box. I’m now stuck having to use dozens of clips where one would suffice if it only supported arrays of references properly.
That’s a clever workaround. A bit clunky in the inspector but workable nonetheless. Hopefully we won’t have to do this in 2020 as it will have native support for seralising generics.