TimelineMode.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using System;
  2. using UnityEngine;
  3. namespace UnityEditor.Timeline
  4. {
  5. enum TimelineModeGUIState
  6. {
  7. Disabled,
  8. Hidden,
  9. Enabled
  10. }
  11. abstract class TimelineMode
  12. {
  13. public struct HeaderState
  14. {
  15. public TimelineModeGUIState breadCrumb;
  16. public TimelineModeGUIState sequenceSelector;
  17. public TimelineModeGUIState options;
  18. }
  19. public struct TrackOptionsState
  20. {
  21. public TimelineModeGUIState newButton;
  22. public TimelineModeGUIState editAsAssetButton;
  23. }
  24. public HeaderState headerState { get; protected set; }
  25. public TrackOptionsState trackOptionsState { get; protected set; }
  26. public TimelineModes mode { get; protected set; }
  27. public abstract bool ShouldShowPlayRange(WindowState state);
  28. public abstract bool ShouldShowTimeCursor(WindowState state);
  29. public virtual bool ShouldShowTrackBindings(WindowState state)
  30. {
  31. return ShouldShowTimeCursor(state);
  32. }
  33. public virtual bool ShouldShowTimeArea(WindowState state)
  34. {
  35. return !state.IsEditingAnEmptyTimeline();
  36. }
  37. public abstract TimelineModeGUIState TrackState(WindowState state);
  38. public abstract TimelineModeGUIState ToolbarState(WindowState state);
  39. public virtual TimelineModeGUIState PreviewState(WindowState state)
  40. {
  41. return state.ignorePreview ? TimelineModeGUIState.Disabled : TimelineModeGUIState.Enabled;
  42. }
  43. public virtual TimelineModeGUIState EditModeButtonsState(WindowState state)
  44. {
  45. return TimelineModeGUIState.Enabled;
  46. }
  47. }
  48. /// <summary>
  49. /// Different mode for Timeline
  50. /// </summary>
  51. [Flags]
  52. public enum TimelineModes
  53. {
  54. /// <summary>
  55. /// A playable director with a valid timeline is selected in editor.
  56. /// </summary>
  57. Active = 1,
  58. /// <summary>
  59. /// The timeline is not editable. (the TimelineAsset file is either readonly on disk or locked by source control).
  60. /// </summary>
  61. ReadOnly = 2,
  62. /// <summary>
  63. /// The timeline cannot be played or previewed.
  64. /// </summary>
  65. Inactive = 4,
  66. /// <summary>
  67. /// Disabled Timeline.
  68. /// </summary>
  69. Disabled = 8,
  70. /// <summary>
  71. /// Timeline in AssetEditing mode.
  72. /// This mode is enabled when a timeline asset is selected in the project window.
  73. /// </summary>
  74. AssetEdition = 16,
  75. /// <summary>
  76. /// The timeline can be edited (either through playable director or selected timeline asset in project window).
  77. /// </summary>
  78. Default = Active | AssetEdition
  79. }
  80. }