---
tags:
    - "Contains"
    - "Attached"
    - "Script"
    - "Behaviour"
    - "Type"
---

# Has Component

[Game Object](index.md) / **Has Component**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

Returns True if the Game Object has the specified Component attached

## Parameters

| Name | Description |
| :--- | :---------- |
| Game Object | The Game Object that is checked |
| Type | The Component type searched for |

## Code

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

namespace VisualScript.Runtime
{
    [Get]

    [Title("Has Component")]
    [Category("Game Object/Has Component")]

    [Description("Returns True if the Game Object has the specified Component attached")]
    [Image(typeof(IconCubeSolid), ColorTheme.Type.TextLight, typeof(BadgeTick))]

    [Parameter("Game Object", "The Game Object that is checked")]
    [Parameter("Type", "The Component type searched for")]

    [Keywords("Contains", "Attached", "Script", "Behaviour", "Type")]

    [Serializable]
    public class TypeBoolGameObjectHasComponent : TypeBool
    {
        [SerializeField] private GetGameObject m_GameObject = new GetGameObject();
        [SerializeField] private TypeReferenceComponent m_Type = new TypeReferenceComponent();

        public override bool Get(Args args)
        {
            GameObject gameObject = this.m_GameObject.Get(args);
            if (gameObject == null) return false;

            Type type = this.m_Type.Type;
            return type != null && gameObject.GetComponent(type) != null;
        }

        public override string ToString()
        {
            return $"{this.m_GameObject} has {this.m_Type}";
        }

        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}

```

