Component is the abstract base class you extend to write gameplay code. Every component lives on a GameObject, and the engine calls its lifecycle methods automatically as the object is created, enabled, updated, and destroyed.
Properties
The
GameObject this component belongs to. Becomes null after the component is destroyed — at which point IsValid also returns false.Shortcut for
GameObject.Scene. The scene this component is in.Shortcut for
GameObject.Transform. See GameTransform for the full reference.Whether this component wants to be active. Does not account for parent
GameObject state — use Active to check whether the component is truly running.True when the component is enabled and its parent
GameObject is active. Lifecycle callbacks such as OnUpdate only run when Active is true.True when the component still has a
GameObject and is in a scene. Use this to guard stale references.The tags of the parent
GameObject. Shortcut for GameObject.Tags.The component list of the parent
GameObject. Shortcut for GameObject.Components.Provides async helpers (
Task.DelaySeconds, etc.) that are automatically cancelled when the GameObject is disabled or destroyed. Use this instead of raw Task.Delay to avoid dangling async operations.World-space transform shortcuts
These properties forward to the parentGameObject’s world transform.
Full world-space transform (position + rotation + scale).
World-space position.
World-space rotation.
World-space scale.
Local-space transform shortcuts
Full local-space transform relative to the parent
GameObject.Position relative to the parent.
Rotation relative to the parent.
Scale relative to the parent.
Lifecycle methods
Override these virtual methods to respond to engine events. You do not need to call the base implementation unless the docs say otherwise.OnAwake
OnEnabled. Called even if the component starts disabled. Use this to cache references to other components.
OnEnabled
OnAwake completes, or whenever Enabled (or the parent GameObject) switches back on.
OnStart
OnUpdate, after the component has been fully initialized and enabled. A good place for one-time setup that depends on the scene being fully loaded.
OnUpdate
Time.Delta is the time elapsed since the last frame, in seconds.
OnUpdate does not run on a dedicated server. Implement server-side logic in OnFixedUpdate.OnFixedUpdate
Time.Delta is the fixed interval. Use this for physics-dependent logic such as applying forces or processing networked input.
OnPreRender
OnDisabled
OnEnabled. Always paired: if OnEnabled ran, OnDisabled will run before the component is destroyed.
OnDestroy
GameObject is set to null.
OnValidate
OnRefresh
[Sync] provides.
OnParentChanged
GameObject changes. Useful for updating cached references that depend on the hierarchy.
OnTagsChanged
GameObject changes. Use this to react to tag-based state changes.
Component query methods
These methods are identical to theGameObject equivalents but operate on the component’s own GameObject.
Other methods
Destroy
GameObject. The component’s OnDisabled and OnDestroy callbacks run before it is removed. The GameObject itself is unaffected.
DestroyGameObject
GameObject and all its components and children. This is a convenience wrapper around GameObject.Destroy().
Invoke
action after secondsDelay seconds. Silently does nothing if the component is no longer active when the delay expires.