using System.Collections.Generic;
using UnityEngine;
namespace Unity.VisualScripting
{
///
/// Selects a value from a set by matching it with an input flow.
///
[UnitCategory("Control")]
[UnitTitle("Select On Flow")]
[UnitShortTitle("Select")]
[UnitSubtitle("On Flow")]
[UnitOrder(8)]
[TypeIcon(typeof(ISelectUnit))]
public sealed class SelectOnFlow : Unit, ISelectUnit
{
[SerializeAs(nameof(branchCount))]
private int _branchCount = 2;
[DoNotSerialize]
[Inspectable, UnitHeaderInspectable("Branches")]
public int branchCount
{
get => _branchCount;
set => _branchCount = Mathf.Clamp(value, 2, 10);
}
[DoNotSerialize]
public Dictionary branches { get; private set; }
///
/// Triggered when any selector is entered.
///
[DoNotSerialize]
[PortLabelHidden]
public ControlOutput exit { get; private set; }
///
/// The selected value.
///
[DoNotSerialize]
[PortLabelHidden]
public ValueOutput selection { get; private set; }
protected override void Definition()
{
branches = new Dictionary();
selection = ValueOutput