---
tags:
    - "Variable"
    - "Local"
    - "Global"
    - "List"
    - "Any"
    - "Value"
---

# Variables

[Variables](index.md) / **Variables**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

The collection of values of a Variable or Local Variable

## Code

```cs
using System;
using System.Collections.Generic;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]

    [Title("Variables")]
    [Category("Variables/Variables")]

    [Description("The collection of values of a Variable or Local Variable")]
    [Image(typeof(IconVariable), ColorTheme.Type.TextLight, typeof(BadgeVariable))]

    [Keywords("Variable", "Local", "Global", "List", "Any", "Value")]

    [Serializable]
    public class TypeCollectionVariables : TTypeCollection<IVariableValue>
    {
        // EXPOSED MEMBERS: -----------------------------------------------------------------------

        [SerializeField] private GetVariable m_Variable;

        // CONSTRUCTORS: --------------------------------------------------------------------------

        public TypeCollectionVariables()
        {
            this.m_Variable = new GetVariable();
        }

        public TypeCollectionVariables(LocalVariable localVariable)
        {
            this.m_Variable = new GetVariable(localVariable);
        }

        public TypeCollectionVariables(GlobalVariable variable)
        {
            this.m_Variable = new GetVariable(variable);
        }

        // PUBLIC METHODS: ------------------------------------------------------------------------

        public override string ToString()
        {
            return this.m_Variable.ToString();
        }

        // PROTECTED METHODS: ---------------------------------------------------------------------

        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;

        protected override void OnCapture(Args args, List<IVariableValue> items)
        {
            Variable variable = this.m_Variable.Get(args);
            if (variable == null) return;

            int count = variable.Count;
            for (int i = 0; i < count; ++i)
            {
                items.Add(variable.Get(i));
            }
        }
    }
}

```

