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

Remove Component#

Game Object / Component / Remove Component

Description#

Removes an existing component from the specified Game Object

Parameters#

Name Description
Game Object The game object reference
Component The type of component to remove

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Title("Remove Component")]
    [Image(typeof(IconCubeOutline), ColorTheme.Type.TextLight, typeof(BadgeMinus))]
    
    [Description("Removes an existing component from the specified Game Object")]
    [Category("Game Object/Component/Remove Component")]
    
    [Parameter("Game Object", "The game object reference")]
    [Parameter("Component", "The type of component to remove")]
    
    [Keywords("Delete", "Destroy")]
    
    [Serializable]
    public class InstructionCoreGameObjectRemoveComponent : Instruction
    {
        [SerializeField] private GetGameObject m_GameObject = new GetGameObject();

        [SerializeField] private TypeReferenceComponent m_Component = new TypeReferenceComponent();

        protected override string GetTitle(GameObject source)
        {
            string component = TextUtils.ThemeAsConstant(this.m_Component.ToString());
            return $"Remove {component} from {this.m_GameObject}";
        }

        protected override Awaitable Run(Args args)
        {
            GameObject gameObject = this.m_GameObject.Get(args);
            if (gameObject != null)
            {
                Component component = gameObject.Get(this.m_Component.Type);
                UnityEngine.Object.Destroy(component);
            }
            
            return Done;
        }
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.