---
tags:
    - "List"
    - "Array"
    - "Element"
    - "Entry"
    - "Position"
    - "Get"
---

# Item at Index

[Collections](index.md) / **Item at Index**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

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

## 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

```cs
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 Texture")]
    [Image(typeof(IconTexture), ColorTheme.Type.Blue, 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 TypeTextureCollectionIndex : TypeTexture
    {
        [SerializeField] private GetCollection m_Collection = new GetCollection();
        [SerializeField] private GetInteger m_Index = new GetInteger(0);

        public override Texture 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 Texture item)
                ? item
                : null;
        }

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

        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}

```

