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

Game Object#

  • Can Read

  • Cannot Write

Description#

A Local Variable attached to a Game Object instance

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]
    
    [Title("Game Object")]
    [Category("Game Object")]
    
    [Description("A Local Variable attached to a Game Object instance")]
    [Image(typeof(IconCubeOutline), ColorTheme.Type.TextLight)]
    
    [Keywords("Component", "Reference")]
    
    [Serializable]
    public class TypeVariableGameObject : TypeVariable
    {
        [SerializeField] private GetGameObject m_GameObject;

        public override Variable GetPreview(GameObject source)
        {
            GameObject gameObject = this.m_GameObject.GetPreview(source);
            return gameObject != null
                ? gameObject.GetComponent<LocalVariable>()
                : null;
        }

        public TypeVariableGameObject()
        {
            this.m_GameObject = new GetGameObject();
        }
        
        public TypeVariableGameObject(GameObject gameObject)
        {
            this.m_GameObject = new GetGameObject(gameObject);
        }
        
        public TypeVariableGameObject(Component component)
        {
            this.m_GameObject = new GetGameObject(component);
        }
        
        public override Variable Get(Args args)
        {
            return this.m_GameObject.Get<LocalVariable>(args);
        }

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

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