i want to create a list of exposed references to use it in unity timeline. I did that as following:
[System.Serializable]
public class PositionAssignment
{
[SerializeField]
private ExposedReference<Character> Character;
[SerializeField]
private ExposedReference<PositionController> PositionController;
}
After that i instantiated the list in my PlayableAsset as following:
public List<PositionAssignment> positionAssignment;
Everything seems to work as expected when the list gets initialized. However when i add a new list element in the inspector window (if elements are already added) it creates a reference to the last element! So when i change the last one the pre-last element changes too and so on.
The List UI automatically makes a copy of an entry, and an ExposedReference is just a tag, so this is expected, but undesired, behaviour.
You could try placing an OnValidate in your PlayableAsset, and changing the exposedName property of the exposed reference fields if they are the same as the previous entry in the list.
Perfect that works great! Do you have a solution for fixing references when duplicating playables? The problem is when i duplicate the playable, both will have the same reference and it updates the playables simultaneously.
I’m also looking for a solution for this. I have a struct that includes an ExposedReference field, which I’m using in a PlayableAsset. When I copy and paste the timeline clip, the exposed reference becomes linked. How can I detect when a clip is duplicated and fix this?
Nothing great. There is no ‘OnDuplicate’ callback mechanism that would be needed to distinguish between a duplicate command and other commands that create the playable asset.
You could write a script that walks the timeline and looks for ExposedReferences with the same name, and renames them. Possibly use the instance id of the object to determine which one is ‘newer’.
Or maybe using some sort of static map along with ISerializationCallbackReceiver to detect duplicate IDs being used.