I watched the entire presentation about custom playables and DefaultPlayables package from James Bouckley and wanted to give the Default Playables asset a try. The whole system is pretty understandable and simple to use - or so I thought, until I tried to use Transform Tween Track and other examples from the Default Playables package which made use of ExposedReference fields within clips. Creating a Transform Tween Track and inserting a clip onto that track greeted me with this inspector:
That inspector shows me the state of a TransformTweenClip class instance, which is organized like this internally - pretty much like the sample tween class covered in the talk:
public class TransformTweenClip : PlayableAsset, ITimelineClipAsset
{
public TransformTweenBehaviour template = new TransformTweenBehaviour ();
public ExposedReference<Transform> startLocation;
public ExposedReference<Transform> endLocation;
...
The inspector is actually drawn from two places. Three fields on top (position, rotation, type) belong to the template container, and are are drawn by TransformTweenDrawer class - an ordinary property drawer class almost exactly replicating one covered in the talk by James.
Below, ExposedReference fields are drawn usingā¦ no idea what (probably some internal class from UnityEditor which I wasnāt able to trace). And this is where I became completely stumped - these fields look wrong and donāt actually give me any way to fill the clip with proper scene references. Letās take a closer look at the first ExposedReference field in this class.
Unfortunately, the talk never featured a single screenshot of an inspector of a clip class with an ExposedReference field in it - nor did any third-party tutorials on YouTube, so Iām just guessing that the inspector renders the field wrong.
But based on my understanding of idea behind ExposedReference struct and on verbal descriptions from the presentation by James, the field should look like an ordinary reference field - a plain box you can drag scene objects into, and it should use the dragged objects to fill the PropertyName exposedName field - for later retrieval of a given object from PlayableGraph through Resolve calls. Instead, what weāre seeing here seems like a ānakedā, default-like inspector for ExposedReference, with the PropertyName and default reference shown directly and no decoration hiding them away. Itās impossible to actually make a clip reference anything in the scene with this inspector - you can validate it yourself by adding logging after Resolve calls into the TransformTweenClip class, like this:
[Serializable]
public class TransformTweenClip : PlayableAsset, ITimelineClipAsset
{
public TransformTweenBehaviour template = new TransformTweenBehaviour ();
public ExposedReference<Transform> startLocation;
public ExposedReference<Transform> endLocation;
public ClipCaps clipCaps
{
get { return ClipCaps.Blending; }
}
public override Playable CreatePlayable (PlayableGraph graph, GameObject owner)
{
var playable = ScriptPlayable<TransformTweenBehaviour>.Create (graph, template);
TransformTweenBehaviour clone = playable.GetBehaviour ();
clone.startLocation = startLocation.Resolve (graph.GetResolver ());
clone.endLocation = endLocation.Resolve (graph.GetResolver ());
Debug.Log
(
"Start location ExposedReference was resolved " + (clone.startLocation == null ? "to null" : "successfully") +
" | End location ExposedReference was resolved " + (clone.endLocation == null ? "to null" : "successfully")
);
return playable;
}
}
Initially, I was wondering whether I misunderstood something and whether default value field was the right place to drag my scene objects into. But logging the resolution results and rechecking the talk confirmed to me that default value field has no effect on resolution (the logs told me the result is always null even if default value is filled) and shouldnāt even be shown in the inspector.
So, to summarize, here is my current understanding of the situation:
- ExposedReference fields are never included into custom property drawers for custom clips
- Instead of making you decorate them directly from a custom clip inspector, Unity has some sort of internal Editor class responsible for drawing a default inspector for these fields
- At some point in the recent past (around 2018.1 at the very latest, which is when I first tried the asset), that internal inspector-generating class was removed or became broken
- As a result, ExposedReference fields are currently not decorated with a proper GUI disguising them as ordinary reference fields and properly filling those fields with data (exposedName).
- Consequently, itās currently impossible to reference anything in clips using ExposedReference fields, like TransformTweenClip from DefaultPlayables asset
Please correct me if Iām wrong somewhere. Maybe itās really a bug that just wasnāt noticed for a while, since none of default Timeline tracks shipping with Unity Editor use ExposedReference fields in the clips, so you can only encounter the issue while checking the Default Playables asset or writing a custom track similar to transform tween example from the talk.