Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


Component

Base class for everything attached to a GameObject.
Read time 4 minutesLast updated 3 days ago

Definition

  • Type: Class
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
  • Inherits from: Object
public class Component : Object

Remarks

Note that your code will never directly create a Component. Instead, you write script code, and attach the script to a GameObject. Additional Resources: ScriptableObject as a way to create scripts that do not attach to any GameObject.

Properties

Property

Description

gameObjectThe game object this component is attached to. A component is always attached to a game object.
tagThe tag of this game object.
transformThe Transform attached to this GameObject.

Methods

Method

Description

BroadcastMessageCalls the method named methodName on every MonoBehaviour in this game object or any of its children.
CompareTagChecks the GameObject's tag against the defined tag.
GetComponentThe string-based version of this method.
GetComponentInChildrenThis is the non-generic version of this method.
GetComponentIndexGets the index of the component on its parent GameObject.
GetComponentInParentThe non-generic version of this method.
GetComponentsThe non-generic version of this method.
GetComponentsInChildrenThe non-generic version of this method.
GetComponentsInParentThe non-generic version of this method.
SendMessageCalls the method named methodName on every MonoBehaviour in this game object.
SendMessageUpwardsCalls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour.
TryGetComponentThe non-generic version of this method.

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.