Legacy Documentation: Version 5.5
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Component.gameObject

public GameObject gameObject;

Description

The game object this component is attached to. A component is always attached to a game object.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void Example() { print(gameObject.name); } }