Documentation index for AI agents (llms.txt) A Markdown version of every page is available: request the page's source under /docs/, follow the "alternate" link in this page's head, or start from /llms.txt.
Visual Script logo Manual

Item at Index#

Collections / Item at Index

  • Can Read

  • Cannot Write

Description#

Reads the item of a collection found at the specified position as a Sprite

Parameters#

Name Description
Collection The collection the item is taken from
Index The zero based position of the item. Returns nothing when out of range

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]

    [Title("Item at Index")]
    [Category("Collections/Item at Index")]

    [Description("Reads the item of a collection found at the specified position as a Sprite")]
    [Image(typeof(IconSprite), ColorTheme.Type.Purple, typeof(BadgeIndex))]

    [Parameter("Collection", "The collection the item is taken from")]
    [Parameter("Index", "The zero based position of the item. Returns nothing when out of range")]

    [Keywords("List", "Array", "Element", "Entry", "Position", "Get")]

    [Serializable]
    public class TypeSpriteCollectionIndex : TypeSprite
    {
        [SerializeField] private GetCollection m_Collection = new GetCollection();
        [SerializeField] private GetInteger m_Index = new GetInteger(0);

        public override Sprite Get(Args args)
        {
            using Args scoped = Args.Get(args);

            int count = this.m_Collection.Capture(scoped);
            int index = this.m_Index.GetInt(args);

            if (index < 0 || index >= count) return null;

            return ArgsCollectionParameters.TryGetItem(this.m_Collection, scoped, index, out Sprite item)
                ? item
                : null;
        }

        public override string ToString()
        {
            return $"{this.m_Collection}[{this.m_Index}]";
        }

        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.