Version: 2019.3
GameObject
Using Components

Introduction to components

A GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary
is an object in the Unity Editor which contains components. Components define the behaviour of that GameObject.

This page describes how to view and interact with components, and provdes a brief overview of the most common component configurations in Unity.

To view a GameObject’s components, select the GameObject in the SceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary
window or Hierarchy window, then see the InspectorA Unity window that displays information about the currently selected GameObject, Asset or Project Settings, alowing you to inspect and edit the values. More info
See in Glossary
window for a list of all components and their settings.

You can interact with components directly in the Editor, or through script. See the Scripting section for guidance on how to control and interact with components through script.

Common component configurations

This section details some fundamental default component configurations in Unity.

Transform component

The Inspector of a new, empty GameObject showing the Transform Component
The Inspector of a new, empty GameObject showing the Transform Component

Every GameObject in Unity has a Transform componentA Transform component determines the Position, Rotation, and Scale of each object in the scene. Every GameObject has a Transform. More info
See in Glossary
. This component defines the GameObject’s position, rotation, and scale in the game world and Scene viewAn interactive view into the world you are creating. You use the Scene View to select and position scenery, characters, cameras, lights, and all other types of Game Object. More info
See in Glossary
. You cannot remove this component.

The Transform component also enables the concept of parenting, which allows you to make a GameObject a child of another GameObject and control its position via the parent’s Transform component. This is a fundamental part of working with GameObjects in Unity.

Main Camera GameObject components

The Main Camera GameObject
The Main Camera GameObject

By default, every new Scene starts with a GameObject called Main Camera. This GameObject is confugured to act as the primary camera in your game. It contains the Transform component, the CameraA component which creates an image of a particular viewpoint in your scene. The output is either drawn to the screen or captured as a texture. More info
See in Glossary
component, and an Audio ListenerA component that acts like a microphone, receiving sound from Audio Sources in the scene and outputting to the computer speakers. More info
See in Glossary
to pick up audio in your application.

GameObject
Using Components
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961