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

Variables#

Variables / Variables

  • Can Read

  • Cannot Write

Description#

The collection of values of a Variable or Local Variable

Code#

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));
            }
        }
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.