namespace Unity.VisualScripting
{
///
/// Triggers the transition in the parent state graph.
///
[UnitSurtitle("State")]
[UnitCategory("Nesting")]
[UnitShortTitle("Trigger Transition")]
[TypeIcon(typeof(IStateTransition))]
public sealed class TriggerStateTransition : Unit
{
///
/// The moment at which the parent state transition should be triggered.
///
[DoNotSerialize]
[PortLabelHidden]
public ControlInput trigger { get; private set; }
protected override void Definition()
{
trigger = ControlInput(nameof(trigger), Trigger);
}
private ControlOutput Trigger(Flow flow)
{
var stateTransition = flow.stack.GetParent();
flow.stack.ExitParentElement();
stateTransition.Branch(flow);
return null;
}
}
}