using System;
using System.Collections;
namespace Unity.VisualScripting
{
///
/// Loops over each element of a collection.
///
[UnitTitle("For Each Loop")]
[UnitCategory("Control")]
[UnitOrder(10)]
public class ForEach : LoopUnit
{
///
/// The collection over which to loop.
///
[DoNotSerialize]
[PortLabelHidden]
public ValueInput collection { get; private set; }
///
/// The current index of the loop.
///
[DoNotSerialize]
[PortLabel("Index")]
public ValueOutput currentIndex { get; private set; }
///
/// The key of the current item of the loop.
///
[DoNotSerialize]
[PortLabel("Key")]
public ValueOutput currentKey { get; private set; }
///
/// The current item of the loop.
///
[DoNotSerialize]
[PortLabel("Item")]
public ValueOutput currentItem { get; private set; }
[Serialize]
[Inspectable, UnitHeaderInspectable("Dictionary")]
[InspectorToggleLeft]
public bool dictionary { get; set; }
protected override void Definition()
{
base.Definition();
if (dictionary)
{
collection = ValueInput(nameof(collection));
}
else
{
collection = ValueInput(nameof(collection));
}
currentIndex = ValueOutput(nameof(currentIndex));
if (dictionary)
{
currentKey = ValueOutput