暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

FlowStateTransitionDescriptor.cs 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System.Linq;
  2. namespace Unity.VisualScripting
  3. {
  4. [Descriptor(typeof(FlowStateTransition))]
  5. public class FlowStateTransitionDescriptor : NesterStateTransitionDescriptor<FlowStateTransition>
  6. {
  7. public FlowStateTransitionDescriptor(FlowStateTransition transition) : base(transition) { }
  8. public override string Title()
  9. {
  10. var graph = transition.nest.graph;
  11. if (graph != null)
  12. {
  13. if (!StringUtility.IsNullOrWhiteSpace(graph.title))
  14. {
  15. return graph.title;
  16. }
  17. using (var recursion = Recursion.New(1))
  18. {
  19. var events = graph.GetUnitsRecursive(recursion).OfType<IEventUnit>().ToList();
  20. if (events.Count == 0)
  21. {
  22. return "(No Event)";
  23. }
  24. else if (events.Count == 1)
  25. {
  26. return events[0].Description().title;
  27. }
  28. else // if (events.Count > 1)
  29. {
  30. return "(Multiple Events)";
  31. }
  32. }
  33. }
  34. else
  35. {
  36. return "(No Transition)";
  37. }
  38. }
  39. public override string Summary()
  40. {
  41. var graph = transition.nest.graph;
  42. if (graph != null)
  43. {
  44. if (!StringUtility.IsNullOrWhiteSpace(graph.summary))
  45. {
  46. return graph.summary;
  47. }
  48. using (var recursion = Recursion.New(1))
  49. {
  50. var events = graph.GetUnitsRecursive(recursion).OfType<IEventUnit>().ToList();
  51. if (events.Count == 0)
  52. {
  53. return "Open the transition graph to add an event.";
  54. }
  55. else if (events.Count == 1)
  56. {
  57. return events[0].Description().summary;
  58. }
  59. else // if (events.Count > 1)
  60. {
  61. return "Open the transition graph to see the full transition.";
  62. }
  63. }
  64. }
  65. else
  66. {
  67. return "Choose a source in the graph inspector.";
  68. }
  69. }
  70. public override EditorTexture Icon()
  71. {
  72. var graph = transition.nest.graph;
  73. using (var recursion = Recursion.New(1))
  74. {
  75. if (graph != null)
  76. {
  77. var events = graph.GetUnitsRecursive(recursion).OfType<IEventUnit>().ToList();
  78. if (events.Count == 1)
  79. {
  80. return events[0].Description().icon;
  81. }
  82. else
  83. {
  84. return typeof(IStateTransition).Icon();
  85. }
  86. }
  87. else
  88. {
  89. return typeof(IStateTransition).Icon();
  90. }
  91. }
  92. }
  93. }
  94. }