No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Marker.cs 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. namespace UnityEngine.Timeline
  3. {
  4. /// <summary>
  5. /// Use Marker as a base class when creating a custom marker.
  6. /// </summary>
  7. /// <remarks>
  8. /// A marker is a point in time.
  9. /// </remarks>
  10. public abstract class Marker : ScriptableObject, IMarker
  11. {
  12. [SerializeField, TimeField, Tooltip("Time for the marker")] double m_Time;
  13. /// <inheritdoc/>
  14. public TrackAsset parent { get; private set; }
  15. /// <inheritdoc/>
  16. /// <remarks>
  17. /// The marker time cannot be negative.
  18. /// </remarks>
  19. public double time
  20. {
  21. get { return m_Time; }
  22. set { m_Time = Math.Max(value, 0); }
  23. }
  24. /// <inheritdoc/>
  25. void IMarker.Initialize(TrackAsset parentTrack)
  26. {
  27. // We only really want to update the parent when the object is first deserialized
  28. // If not a cloned track would "steal" the source's markers
  29. if (parent == null)
  30. {
  31. parent = parentTrack;
  32. try
  33. {
  34. OnInitialize(parentTrack);
  35. }
  36. catch (Exception e)
  37. {
  38. Debug.LogError(e.Message, this);
  39. }
  40. }
  41. }
  42. /// <summary>
  43. /// Override this method to receive a callback when the marker is initialized.
  44. /// </summary>
  45. /// <param name="aPent">The track that contains the marker.</param>
  46. public virtual void OnInitialize(TrackAsset aPent)
  47. {
  48. }
  49. }
  50. }