123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using System.Linq;
-
- namespace Unity.VisualScripting
- {
- [Descriptor(typeof(FlowStateTransition))]
- public class FlowStateTransitionDescriptor : NesterStateTransitionDescriptor<FlowStateTransition>
- {
- public FlowStateTransitionDescriptor(FlowStateTransition transition) : base(transition) { }
-
- public override string Title()
- {
- var graph = transition.nest.graph;
-
- if (graph != null)
- {
- if (!StringUtility.IsNullOrWhiteSpace(graph.title))
- {
- return graph.title;
- }
-
- using (var recursion = Recursion.New(1))
- {
- var events = graph.GetUnitsRecursive(recursion).OfType<IEventUnit>().ToList();
-
- if (events.Count == 0)
- {
- return "(No Event)";
- }
- else if (events.Count == 1)
- {
- return events[0].Description().title;
- }
- else // if (events.Count > 1)
- {
- return "(Multiple Events)";
- }
- }
- }
- else
- {
- return "(No Transition)";
- }
- }
-
- public override string Summary()
- {
- var graph = transition.nest.graph;
-
- if (graph != null)
- {
- if (!StringUtility.IsNullOrWhiteSpace(graph.summary))
- {
- return graph.summary;
- }
-
- using (var recursion = Recursion.New(1))
- {
- var events = graph.GetUnitsRecursive(recursion).OfType<IEventUnit>().ToList();
-
- if (events.Count == 0)
- {
- return "Open the transition graph to add an event.";
- }
- else if (events.Count == 1)
- {
- return events[0].Description().summary;
- }
- else // if (events.Count > 1)
- {
- return "Open the transition graph to see the full transition.";
- }
- }
- }
- else
- {
- return "Choose a source in the graph inspector.";
- }
- }
-
- public override EditorTexture Icon()
- {
- var graph = transition.nest.graph;
-
- using (var recursion = Recursion.New(1))
- {
- if (graph != null)
- {
- var events = graph.GetUnitsRecursive(recursion).OfType<IEventUnit>().ToList();
-
- if (events.Count == 1)
- {
- return events[0].Description().icon;
- }
- else
- {
- return typeof(IStateTransition).Icon();
- }
- }
- else
- {
- return typeof(IStateTransition).Icon();
- }
- }
- }
- }
- }
|