Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.3 has arrived! Read about it here.
    Dismiss Notice
  3. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Exposed reference for data in List<>

Discussion in 'Timeline' started by dejmil82, Sep 26, 2017.

  1. dejmil82

    dejmil82

    Joined:
    Mar 5, 2013
    Posts:
    1
    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.

    Code (CSharp):
    1. [Serializable]
    2. public class MyCustomBehaviour : PlayableBehaviour
    3. {
    4.     public Transform myTransform;
    5. }
    6.  
    7. [Serializable]
    8. public class MyCustomClip : PlayableAsset, ITimelineClipAsset
    9. {
    10.     public MyCustomBehaviour data = new MyCustomBehaviour();
    11.     public ExposedReference<Transform> exposedTransform;
    12.  
    13.     public ClipCaps clipCaps
    14.     {
    15.         get { return ClipCaps.None; }
    16.     }
    17.  
    18.     public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
    19.     {
    20.         var playable = ScriptPlayable<MyCustomBehaviour>.Create(graph, data);
    21.  
    22.         MyCustomBehaviour clone = playable.GetBehaviour();
    23.         clone.myTransform = exposedTransform.Resolve(graph.GetResolver());
    24.  
    25.         return playable;
    26.     }
    27. }
    But, how to expose variable that is inside complex data structure, like this:

    Code (CSharp):
    1. [Serializable]
    2. public class MyCustomBehaviour : PlayableBehaviour
    3. {
    4.     [Serializable]
    5.     public class MyCustomClass
    6.     {
    7.         //How to expose this variable?
    8.         public Transform myTransform;
    9.     }
    10.  
    11.     public List<MyCustomClass> myCustomClassesList = new List<MyCustomClass>();
    12. }
     
  2. coolabananers

    coolabananers

    Joined:
    Mar 16, 2013
    Posts:
    1
    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<Transform>> 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.
     
  3. caihua

    caihua

    Joined:
    Nov 5, 2014
    Posts:
    7
    I hava the same problem, i think this's a bug or defect for Timeline.
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    233
    It's a known issue that arrays and list of exposed references don't serialize and won't work correctly.
     
  5. arisvang

    arisvang

    Joined:
    Sep 10, 2014
    Posts:
    4
    ^ is it fixed in the new version?
     
  6. streeter12

    streeter12

    Joined:
    Mar 28, 2015
    Posts:
    2
    No, have same issue on 2017.3.0.
     
  7. valtovar

    valtovar

    Joined:
    Dec 22, 2013
    Posts:
    3
    Hey, to workaround this problem use this approach.


    [Serializable]
    public class MyThing
    {
    [SerializeField]
    public ExposedReference<GameObject> thing;
    }

    public class TestSerializable : MonoBehaviour
    {
    public List<MyThing> myThingList;
    }
     
    seant_unity likes this.