Count#
Collections / Count
Can Read
Cannot Write
Description#
How many items a collection has
Parameters#
| Name | Description |
|---|---|
| Collection | The collection whose items are counted |
Code#
using System;
using UnityEngine;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Title("Count")]
[Category("Collections/Count")]
[Description("How many items a collection has")]
[Image(typeof(IconStack), ColorTheme.Type.Teal, typeof(BadgeHash))]
[Parameter("Collection", "The collection whose items are counted")]
[Keywords("Length", "Size", "Amount", "Total", "List", "Array")]
[Serializable]
public class TypeNumberCollectionCount : TypeNumber
{
[SerializeField] private GetCollection m_Collection = new GetCollection();
public override double Get(Args args)
{
return this.m_Collection.Capture(args);
}
public override string ToString()
{
return $"Count of {this.m_Collection}";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}