Search Unity

Custom MarkerTrack not saving/serializing markers

Discussion in 'Timeline' started by nturleymb, Apr 15, 2020.

  1. nturleymb

    nturleymb

    Joined:
    Mar 31, 2020
    Posts:
    6
    Hi,

    I've been trying to get a custom marker type working to use with our event system.

    I have a custom MarkerTrack:

    Code (CSharp):
    1.  
    2. [TrackBindingType(typeof(CustomMarkerMessageReceiver ))]
    3. [TrackColor(0.08f, 0.695f, 0.64f)]
    4. public class CustomEventTrack : MarkerTrack
    5. {
    6.  
    7. }
    8.  
    A custom MessageReceiver

    Code (CSharp):
    1.  
    2.  
    3. public class CustomMarkerMessageReceiver : MonoBehaviour, INotificationReceiver
    4. {
    5.     public void OnNotify(Playable origin, INotification notification, object context)
    6.     {
    7.  
    8.         // DO stuff with the event
    9.      
    10.     }
    11. }
    12.  
    13.  
    and a Custom Marker

    Code (CSharp):
    1.  
    2.  
    3. public class CustomMarkerSignalEmitter : Marker, INotification
    4. {
    5.     public PropertyName id { get { return new PropertyName(); } }
    6. }
    7.  
    8.  
    It's all working and the events are being passed to the Receiver, however when I save everything and push to git, other devs don't see the markers I added in the track when they pull

    It seems like somehow the markers aren't getting saved or serialized with everything else. Is there something I'm missing? Seems like the Track is maybe not taking care of serializing my Markers, is there something I need to do manually?

    Thanks
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    A couple things you can check:

    1. Check that the file with the CustomMarkerSignalEmitter class is named CustomMarkerSignalEmitter.cs. Since the marker is a Unity object (ScriptableObject to be precise), the class name must match the file name.

    2. If you are creating timelines from script, make sure you add the timeline to the asset database before adding markers.
     
  3. nturleymb

    nturleymb

    Joined:
    Mar 31, 2020
    Posts:
    6
    Ok I think that was the issue #1 that is. Seems that the markers are now syncing properly.

    Thanks!

    One thing I just noticed tho... The reference to my CustomMarkerMessageReceiver was not saved in the timeline track until I saved/pushed the scene. Is this normal? not ideal to have to push a scene in order for those references to work, but maybe that wasn't actually the case.
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Yes - the signal emitter is saved with the timeline. The signal asset is independent of both scene and signal emitter. The signal receiver is part of the scene.

    This allows you to make the reaction based on who is receiving the signal. For example, if you dynamically change which character is being affected by the timeline, they can play different audio, or effects based on which signals are received.

    If also allows different timelines to reuse signals.

    This is why we went with the name signal, instead of event -- the timeline signals what happened, and the receiver decides how to react.