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

Local Variable#

Components / Variables / Local Variable

  • Can Read

  • Cannot Write

Description#

The Local Variable component attached to a Game Object

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]
    
    [Inline(nameof(m_Value), typeof(LocalVariable), true)]
    
    [Title("Local Variable")]
    [Category("Components/Variables/Local Variable")]
    [Description("The Local Variable component attached to a Game Object")]
    
    [Image(typeof(IconVariable), ColorTheme.Type.TextLight, typeof(BadgeVariable))]
    [Keywords("Variable")]
    
    [Serializable]
    public class TypeGameObjectComponentLocalVariable : TypeGameObject
    {
        [SerializeField] private LocalVariable m_Value;
        
        public TypeGameObjectComponentLocalVariable()
        {
            this.m_Value = null;
        }
        
        public TypeGameObjectComponentLocalVariable(LocalVariable component)
        {
            this.m_Value = component;
        }

        public override GameObject GetPreview(GameObject source) =>
            this.m_Value != null
                ? this.m_Value.gameObject
                : null;

        public override GameObject Get(Args args)
        {
            return this.m_Value != null
                ? this.m_Value.gameObject
                : null;
        }
        
        public override U Get<U>(Args args)
        {
            if (typeof(U) == typeof(LocalVariable))
            {
                return this.m_Value != null
                    ? this.m_Value as U
                    : null;
            }
            
            return base.Get<U>(args);
        }
        
        public override string ToString()
        {
            return TextUtils.Name(this.m_Value);
        }
        
        protected override SubscriptionMode Subscription => SubscriptionMode.OnEditorChange;
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.