Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

TimelineItemGUI.cs 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine.Timeline;
  4. using UnityEngine;
  5. namespace UnityEditor.Timeline
  6. {
  7. static class ItemToItemGui
  8. {
  9. static Dictionary<object, TimelineItemGUI> s_ItemToItemGUI =
  10. new Dictionary<object, TimelineItemGUI>();
  11. public static void Add(TimelineClip clip, TimelineItemGUI gui)
  12. {
  13. s_ItemToItemGUI[clip] = gui;
  14. }
  15. public static void Add(IMarker marker, TimelineItemGUI gui)
  16. {
  17. s_ItemToItemGUI[marker] = gui;
  18. }
  19. public static TimelineClipGUI GetGuiForClip(TimelineClip clip)
  20. {
  21. return GetGuiForItem(clip) as TimelineClipGUI;
  22. }
  23. public static TimelineMarkerGUI GetGuiForMarker(IMarker marker)
  24. {
  25. return GetGuiForItem(marker) as TimelineMarkerGUI;
  26. }
  27. static TimelineItemGUI GetGuiForItem(object item)
  28. {
  29. if (item == null)
  30. return null;
  31. TimelineItemGUI gui;
  32. s_ItemToItemGUI.TryGetValue(item, out gui);
  33. return gui;
  34. }
  35. }
  36. abstract class TimelineItemGUI : ISelectable
  37. {
  38. protected readonly DirectorStyles m_Styles;
  39. public abstract ITimelineItem item { get; }
  40. public abstract double start { get; }
  41. public abstract double end { get; }
  42. public abstract void Draw(Rect rect, bool rectChanged, WindowState state);
  43. public abstract Rect RectToTimeline(Rect trackRect, WindowState state);
  44. public virtual void Select() { }
  45. public virtual bool IsSelected() { return false; }
  46. public virtual void Deselect() { }
  47. public virtual bool CanSelect(Event evt) { return true; }
  48. public virtual void StartDrag() { }
  49. public virtual void StopDrag() { }
  50. public LayerZOrder zOrder { get; set; }
  51. public bool visible { get; set; }
  52. public bool isInvalid { get; set; }
  53. public IRowGUI parent { get; }
  54. public Rect rect
  55. {
  56. get { return parent.ToWindowSpace(treeViewRect); }
  57. }
  58. public Rect treeViewRect
  59. {
  60. get { return m_TreeViewRect; }
  61. protected set
  62. {
  63. m_TreeViewRect = value;
  64. if (value.width < 0.0f)
  65. m_TreeViewRect.width = 1.0f;
  66. }
  67. }
  68. Rect m_TreeViewRect;
  69. protected TimelineItemGUI(IRowGUI parent)
  70. {
  71. this.parent = parent;
  72. m_Styles = DirectorStyles.Instance;
  73. }
  74. }
  75. }