# Component

> Base class for everything that can be attached to a GameObject.

## Definition

* **Type:** Class
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule
* **Inherits from:** [Object](/engine/6000.7/script-reference/unityengine/object.md)

```csharp
public class Component : Object
```

## Remarks

Note that you don't instantiate the `Component` class directly. Instead, you write code in [MonoBehaviour](/engine/6000.7/script-reference/unityengine/monobehaviour.md) scripts, which inherit from `Component`, and attach the scripts to a [GameObject](/engine/6000.7/script-reference/unityengine/gameobject.md). Additional Resources: [ScriptableObject](/engine/6000.7/script-reference/unityengine/scriptableobject.md) as a way to create scripts that do not attach to any [GameObject](/engine/6000.7/script-reference/unityengine/gameobject.md).

## Properties

| Property                                                                                    | Description                                                                                                                                                            |
| ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [gameObject](/engine/6000.7/script-reference/unityengine/component/gameobject.md)           | The game object this component is attached to. A component is always attached to a game object.                                                                        |
| [tag](/engine/6000.7/script-reference/unityengine/component/tag.md)                         | The tag of this game object.                                                                                                                                           |
| [transform](/engine/6000.7/script-reference/unityengine/component/transform.md)             | The [Transform](/engine/6000.7/script-reference/unityengine/transform.md) attached to this [GameObject](/engine/6000.7/script-reference/unityengine/gameobject.md).    |
| [transformHandle](/engine/6000.7/script-reference/unityengine/component/transformhandle.md) | The [TransformHandle](/engine/6000.7/script-reference/unityengine/transformhandle.md) of this [GameObject](/engine/6000.7/script-reference/unityengine/gameobject.md). |

## Methods

| Method                                                                                                      | Description                                                                                                                                                                            |
| ----------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [BroadcastMessage](/engine/6000.7/script-reference/unityengine/component/broadcastmessage.md)               | Calls the method named `methodName` on every [MonoBehaviour](/engine/6000.7/script-reference/unityengine/monobehaviour.md) in this game object or any of its children.                 |
| [CompareTag](/engine/6000.7/script-reference/unityengine/component/comparetag.md)                           | Checks the GameObject's tag against the defined `tag`.                                                                                                                                 |
| [GetComponent](/engine/6000.7/script-reference/unityengine/component/getcomponent.md)                       | The string-based version of this method.                                                                                                                                               |
| [GetComponentInChildren](/engine/6000.7/script-reference/unityengine/component/getcomponentinchildren.md)   | This is the non-generic version of this method.                                                                                                                                        |
| [GetComponentIndex](/engine/6000.7/script-reference/unityengine/component/getcomponentindex.md)             | Gets the index of the component on its parent GameObject.                                                                                                                              |
| [GetComponentInParent](/engine/6000.7/script-reference/unityengine/component/getcomponentinparent.md)       | The non-generic version of this method.                                                                                                                                                |
| [GetComponents](/engine/6000.7/script-reference/unityengine/component/getcomponents.md)                     | The non-generic version of this method.                                                                                                                                                |
| [GetComponentsInChildren](/engine/6000.7/script-reference/unityengine/component/getcomponentsinchildren.md) | The non-generic version of this method.                                                                                                                                                |
| [GetComponentsInParent](/engine/6000.7/script-reference/unityengine/component/getcomponentsinparent.md)     | The non-generic version of this method.                                                                                                                                                |
| [SendMessage](/engine/6000.7/script-reference/unityengine/component/sendmessage.md)                         | Calls the method named `methodName` on every [MonoBehaviour](/engine/6000.7/script-reference/unityengine/monobehaviour.md) in this game object.                                        |
| [SendMessageUpwards](/engine/6000.7/script-reference/unityengine/component/sendmessageupwards.md)           | Calls the method named `methodName` on every [MonoBehaviour](/engine/6000.7/script-reference/unityengine/monobehaviour.md) in this game object and on every ancestor of the behaviour. |
| [TryGetComponent](/engine/6000.7/script-reference/unityengine/component/trygetcomponent.md)                 | The non-generic version of this method.                                                                                                                                                |

## Inheritance

**Inherited Members:**

* [Object.GetEntityId()](/engine/6000.7/script-reference/unityengine/object/getentityid.md)
* [Object.GetHashCode()](/engine/6000.7/script-reference/unityengine/object/gethashcode.md)
* [Object.InstantiateAsync\<T>(T)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Transform, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, Vector3, Quaternion, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Transform, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, InstantiateParameters, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, InstantiateParameters, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, Vector3, Quaternion, InstantiateParameters, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.InstantiateAsync\<T>(T, int, ReadOnlySpan\<Vector3>, ReadOnlySpan\<Quaternion>, InstantiateParameters, CancellationToken)](/engine/6000.7/script-reference/unityengine/object/instantiateasync.md)
* [Object.Instantiate(Object, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion\))
* [Object.Instantiate(Object, Vector3, Quaternion, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object-vector3-quaternion-transform\))
* [Object.Instantiate(Object)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object\))
* [Object.Instantiate(Object, Scene)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object-scene\))
* [Object.Instantiate\<T>(T, InstantiateParameters)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, InstantiateParameters)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate(Object, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform\))
* [Object.Instantiate(Object, Transform, bool)](/engine/6000.7/script-reference/unityengine/object/instantiate.md#instantiate\(object-transform-bool\))
* [Object.Instantiate\<T>(T)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Vector3, Quaternion, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Instantiate\<T>(T, Transform, bool)](/engine/6000.7/script-reference/unityengine/object/instantiate.md)
* [Object.Destroy(Object, float)](/engine/6000.7/script-reference/unityengine/object/destroy.md)
* [Object.DestroyImmediate(Object, bool)](/engine/6000.7/script-reference/unityengine/object/destroyimmediate.md)
* [Object.FindObjectsByType(Type)](/engine/6000.7/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type\))
* [Object.FindObjectsByType(Type, FindObjectsInactive)](/engine/6000.7/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytype\(type-findobjectsinactive\))
* [Object.DontDestroyOnLoad(Object)](/engine/6000.7/script-reference/unityengine/object/dontdestroyonload.md)
* [Object.FindAnyObjectByType\<T>()](/engine/6000.7/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(\))
* [Object.FindAnyObjectByType\<T>(FindObjectsInactive)](/engine/6000.7/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytypet\(findobjectsinactive\))
* [Object.FindObjectsByType\<T>()](/engine/6000.7/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(\))
* [Object.FindObjectsByType\<T>(FindObjectsInactive)](/engine/6000.7/script-reference/unityengine/object/findobjectsbytype.md#findobjectsbytypet\(findobjectsinactive\))
* [Object.FindAnyObjectByType(Type)](/engine/6000.7/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type\))
* [Object.FindAnyObjectByType(Type, FindObjectsInactive)](/engine/6000.7/script-reference/unityengine/object/findanyobjectbytype.md#findanyobjectbytype\(type-findobjectsinactive\))
* [Object.ToString()](/engine/6000.7/script-reference/unityengine/object/tostring.md)
* [Object.name](/engine/6000.7/script-reference/unityengine/object/name.md)
* [Object.hideFlags](/engine/6000.7/script-reference/unityengine/object/hideflags.md)

### Operators

| Operator                                                                           | Description                                                             |
| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [operator ==](/engine/6000.7/script-reference/unityengine/object/op-equality.md)   | Compares two object references to see if they refer to the same object. |
| [bool](/engine/6000.7/script-reference/unityengine/object/op-implicit.md)          | Determines whether the object exists.                                   |
| [operator !=](/engine/6000.7/script-reference/unityengine/object/op-inequality.md) | Compares if two objects refer to a different object.                    |
