◀ 1.11.21.3 ▶

1.2 — The Unity Editor Tour

Before you write a line of code you need to read the tool that runs everything. Unity is five panes, one Inspector, and a trap called play mode — and it ends with something strange about the Player in this project.

In the Editor~25 min
  1. Hierarchy → left. Every GameObject in this scene, as a tree. Click things: some entries are parents with children indented under them — why?
  2. Scene view → centre. The world, editable from above. Scroll to zoom, right-drag to pan, press F to focus the selected object.
  3. Game view → what the camera sees. Press Play and watch the focus jump to this tab by itself.
  4. Inspector → right. Everything about the selected object, as a list of components. Select the Player and read the whole list.
  5. Project window → bottom. The repo's actual files. Navigate to Assets/Scripts and click PlayerController.cs.
  6. Game view → press Play, select the Player, and set Inspector → Transform → Position X to 15. The character teleports across the screen. Press Play again to stop and it is back where it started, with your 15 gone.
    Inspector showing PlayerInspectorPlayerTransform6PositionX 15 Y 0 Z 0RotationX 0 Y 0 Z 0ScaleX 1 Y 1 Z 1Player Controller (Script)
    The Player's Inspector. Transform is the first component on every object in the game, and Position is the first row inside it — the box this step wants is the first of that row's three. Your numbers will differ; the row is what matters.
  7. File → Save (or Ctrl+S) so the work you did keep is written to disk, then commit it in GitHub Desktop.
Play mode is a dream, edit mode is reality. Everything you change while the Play button is blue — positions, Inspector values, objects dragged into the scene — evaporates the moment you stop. That is the point: you can test an idea without risking the game you have. Experiment in play mode, then stop and enter the winning numbers in edit mode to keep them.
In the Code~20 min

One idea to carry out of today: a GameObject is an empty container, and components are the abilities you bolt onto it. Here is every component the Player has.

ObjectComponentWhat it does here
Player (tagged Player)TransformPosition, rotation and scale. Every GameObject has one.
PlayerPlayer Controller (Script)A nearly empty script. One line in Start() switches the idle animation on; it has no fields and it does not move anything.
Sprite (child of Player)TransformPosition relative to its parent — which is why children move when the parent moves.
SpriteSprite RendererWhat you actually see. The Player root has none, which is why the Player itself is invisible.
SpriteAnimatorThe idle animation that plays when you press Play.

Socratic

  1. Why would Unity be designed so that play-mode changes vanish? Think about testing an idea fifty times a day — what does "reset to the last known good game" buy you?
  2. The Player carries two components and the Sprite carries three. Which object would you move to move the character, and what would happen to the picture if you moved the child instead?
  3. Is play mode closer to a save-file system or to an undo button, and why?

Checkpoint — before moving on, you must be able to:

Reference Docs

Need a deeper explanation? These pages cover the same concepts:

Next: 1.3 — Your First Script: Variables & Update, where the empty script on the Player gets its first real lines.

0/3 answered

Answers save on this device as you type. At the end of class, click Download and upload the file to the Canvas assignment.

Saved on this device only — the Dashboard tracks your progress.