Set ExposedReference<T> Value

I have a PlayableBehaviour which has a serialised ExposedRerence field. I have a PlayableTrack which checks its timeline clips and if it encounters a clip whose asset is a game object (after dragging and dropping a game object on the track), it removes the clip and creates a new PlayableBehaviour timeline clip instead.

That's all fine, but what I need to do is grab a component on the previously mentioned game object and assign the newly created PlayableBehaviour's ExposedRerence field to this component.

How do I do this?

One thing I have tried which failed is to get the resolver on the current graph and set its reference value using IExposedPropertyTable.SetReferenceValue. If I then check that I was successful with GetReferenceValue, I see that I am indeed setting it, but nothing is updating in the editor. Am I working on the wrong graph? Or is this approach fundamentally misguided? Any help at all is mightily appreciated.

The following PlayableBehaviour will create a new GameObject and set it to the graph's resolver. If you use the exposedReference's exposedName when calling SetReferenceValue, it should work. Let me know if this fixes your issue.

public class TestPlayable : BasicPlayableBehaviour {

    [SerializeField] public ExposedReference<GameObject> reference;

    public override void OnPlayableCreate(Playable playable)
        GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane); = "TestGO";
        playable.GetGraph().GetResolver().SetReferenceValue(reference.exposedName, plane);
1 Like

That sneaky exposedName property was definitely what I needed! Can't believe I missed that. Thanks a bunch!

Now that the assignment is working, I have discovered another small issue which I hope you could point me in the right direction on?

I think I might be doing things a bit differently (or maybe incorrectly) for the following reasons:

  • What is BasicPlayableBehaviour? I've seen this multiple times and don't know how people have access to it.
  • I can't think of a use case where having an exposed reference on a playable behaviour will be useful. Maybe I'm lacking in imagination! Wouldn't it make more sense to have a playable asset have an exposed reference because at least then we have access to it in the editor to assign scene references.

Following on from point 2, I have this situation:

  • I have a CustomPlayableTrack which, on CreateTrackMixer, uses CreateDefaultClip to instantiate a CustomPlayableAsset. I then call an init method on this playable asset which passes through an object reference and the graph reference received with CreateTrackMixer.
  • The playable asset then uses the given graph from the track to update an ExposedReference value with the given object reference.
  • The playable asset then receives a call to CreatePlayable, where it resolves the previously set exposed reference on the graph received through CreatePlayable. It instantiates a ScriptPlayable and passes through the resolved reference.

This actually all works now given use of exposedName. However, whenever I perform the above more than once, all assets on the track have their references updated with the latest object.

I think this is to do with using the track's graph to set the reference value on my CustomPlayableAsset*s. How would I go about setting the reference value on my *CustomPlayableAsset when I don't have access to a graph? Note that this happens before the call to my asset's CreatePlayable method, which typically passes the correct graph.

A BasicPlayableBehaviour combines both a PlayableAsset and a PlayableBehaviour. It is meant to simplify things and avoid users having to create two classes. It is also simpler when writing examples ;) Having a PlayableAsset/PlayableBehaviour pair is the preferred way, since a BasicPlayableBehaviour is more costly on performance.

You are right that, on a PlayableBehaviour, an exposed reference doesn’t make any sense. The exposed references normally go into a PlayableAsset. See it like this: the PlayableAsset contains the data necessary for your PlayableBehaviour to function as the PlayableAsset is used to create the PlayableBehaviour. That’s why they normally they come in pairs.

As for your CustomPlayableAsset and exposed properties issue, could you post a sample of your code? There are many moving parts here and having the code could help me find what’s happening.

Hey guys!

I am having a similar issue. In Beta1 of 2017 I was able to create a playbleasset and playable behavior (when they were two separate scripts)

Now, having upgraded to a more recent beta, it seems the api has changed, and the docs are not up to date yet.

I was following the Beta12017 PDF to create a playable asset and behavior, however I am not sure how to do it with the new api.

Thanks for any insight, I look forward to using Timeline!

Thanks for the clarification julienb. I'm glad my intuition on playable assets vs behaviours is correct.

It will take a little time my end to extract only the relevant scripts exhibiting the behaviour, as I don't want to give you a project with masses of irrelevant complexity. I hope to find time to do that this week, and will update here with the files ASAP.

Thanks again for your support.

1 Like


I recommend you to download the recently updated example project at the bottom of the first post here:

It was very helpful to see some working sample code in action. It will surely help you too!

1 Like

Thanks! Will do!!

hello guys,
I am having kind of the same issue too, with Cinemachine :

I am creating a default Cinemachine Shot in the Timeline, and then I want to set its VirtualCamera.
But the field is ExposedReference, so it doesn't work...

Any clue ?

Thanks a lot

internal sealed class CinemachineShotPlayable : PlayableBehaviour
        public CinemachineVirtualCameraBase VirtualCamera;

    public sealed class CinemachineShot : PlayableAsset, IPropertyPreview
        public ExposedReference<CinemachineVirtualCameraBase> VirtualCamera;

        public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
            var playable = ScriptPlayable<CinemachineShotPlayable>.Create(graph);
            playable.GetBehaviour().VirtualCamera = VirtualCamera.Resolve(graph.GetResolver());
            return playable;


I know dude, it wasn't very intuitive for me until a friend showed me how to do it. Take a look at this screenshot:

There is a drop down menu that lets you select the active Timeline or something. You can't seem to apply objects to Timeline scripts if you don't do this, despite the values remaining open. Hope this helps you too!!

Hi Angelus1818,
actually it's not really my problem : I can already access my timeline via script.
The issue is that I want to create a new CinemachineShot and set its Virtual Camera but
- I don't know how to create a Cinemachine Shot via script : the only way I found to do so is creating a default clip in the Cinemachine Track
- When I have my Cinemachine Shot, I don't know how to set its Virtual Camera field because it is an ExposedReference...

See my answer here.

1 Like

Hey just in case anyone has the same issue that David Foster had with every clip getting the last reference:

You have to generate a new exposedName for it like so:

exposedRef.exposedName = UnityEditor.GUID.Generate().ToString()
1 Like