Unity Editor πŸ•ΉοΈ

The Unity Editor is where we will build and assemble our games. Unity Editor versions are managed by Unity Hub which can download here.

It's recommended to pick an LTS version of the Unity Editor, as they are stable versions. They will still receive patches for 2 years.

✍️ Heavily refer to the Official Documentation.

πŸš€ There are multiple ways to achieve the same goal. Some may use buttons, some may use shortcuts, others may use the toolbar.

This content is further developed in other pages:

⚠️ Warning: content under development. Last update: 2021.


Component-based architecture

Game Object

Every entity in the game world is a game object:

  • Characters and Items
  • Lights and Cameras
  • Sounds and Musics
  • UI Elements
  • ...

A game object can contain other game objects.

πŸ“š Prefabs are preconfigured GameObjects that we can create and reuse throughout our project.

Components

Unity uses a component-based architecture, where you attach various components to GameObjects to give them specific functionality.

Every game object has a TransformComponent handling the position, rotation, and scale of a Game object.

We can create our components using Scripts.

Scenes

Scenes are individual levels or sections of your game. We often have one scene per screen.


Unity Editor Interface

Editor Interface

The editor is divided into four windows:

  1. hierarchy window πŸ“š: list of all game objects in the scene
  2. scene window πŸ› : show the scene tab by default.
    • scene tab: edit your scene
    • game tab: run your scene
  3. inspector window βš™: edit the properties of the selected object
  4. project window πŸ—„: all of your project files

➑️ When running the game, the scene tab will still be available, but any changes to it will be discarded when the simulation stops.

✍️ Some are using a color tint (Edit > Preferences > Colors > Playmode tint) to visually see when their changes will be discarded.


Basic Editor Usage

In most windows, using right-click, you can create game objects, components, scripts, etc.

Hierarchy - Create game objects

Hierarchy window

The order of elements is important in 2D. Elements at the top are rendered before/below the ones at the bottom.

  • Double-click on an item to focus it in the scene view
  • F2 to rename the selected item
  • CTRL+D to duplicate the selected item
  • ALT+expand/hide: to expand/hide all children of a group
  • SearchBar: search game objects or components (write the fullname)

Scene window

You can move, rotate, and scale game objects. You can also change your point of view by clicking on an axis. Click back on the square to go back to Perspective.

Scene window - icons Β  Unity Point of View Axis

  • F to focus a game object
  • Mouse Wheel to zoom/unzoom
  • Left-Click/Middle-click to move your point of view
  • CTRL when moving something will update the position by 0.25
  • CTRL/SHIFT to select multiple game objects

Inspector Window

We can edit the properties of any selected game objected (from the hierarchy or from the project view). We can also manipulate components:

Unity inspector - remove component

Some values are game objects or files. You can drag and drop the game object/file to the field. You can also use the small circle with a dot, to browse values for this field (Unity pick value).

πŸ“š You can drag-and-drop a component to a game object in the hierarchy/scene to add it to a game object (a shortcut).


Project Window

The project window is like a warehouse. It's a file explorer allowing you to browse your scenes, your assets and open them in Unity. We usually sort our assets in folders such as:

  • Animations, Audio, Cutscene
  • Images, Materials
  • Plugins, Prefabs, Scenes
  • Scripts
  • Settings, Shaders

➑️ You can create scenes, materials, scripts, etc. from there.


Manipulating Game Objects

Every Game object has the same properties:

Unity inspector

  1. Enable/Disable
  2. Name
  3. Tag
  4. Transform
  5. Add new components

A game object that is disabled is neither updated nor rendered.

Pros are disabling game objects that are far from the camera and only enabling those near the camera. In some cases, we may show objects that are far away if they are visible to the player (ex: building, etc.).

⚠️ Avoid using scaling. It may cause performance issues.


Game Object Nesting

You can nest game objects inside game objects. While it makes everything look cleaner, too much nesting decreases performance.

Nested objects are rendered relatively to their parents. It means that moving the parent will move the children.

Hierarchy - groups

πŸ“š If the parent is disabled, its nested game objects are disabled too. One trick is to disable the renderer instead of the game object.

Prefabs πŸ€–

We can save a Game Object inside a file as a prefab. Each time we add a prefab to a scene, it creates a new instance.

When we modify the prefab, every instance is modified. But each instance can independently make some changes. In that scenario, the changes of the prefab are not overriding the local changes.

  • βœ… We update only one game object to update all instances
  • βœ… Changing the Transform Component doesn't impact instances
  • ❌ If we change the prefab, we may create problems as we have very little control over what instances did change on their side.

To create a prefab, drag and drop a game object from the scene or the hierarchy to a folder in the project window. Do the reverse process to create an instance. Instances have a blue logo in the hierarchy 🟦.

If an instance modifies the prefab, a blue bar is shown next to each modified property and any different value is in bold. Use right-click on a property to apply/revert changes. You can see every overridden property by clicking on "override," right below "layer."

Double-click on a prefab to edit it. From the inspector, you can also use the arrow at the top.

πŸ“š Prefab means "Prefabricated Game Object."


Unity Asset Store πŸͺ

You can access Unity Asset Store directly from Unity Editor.

  • Window > Asset store: open the asset store in your browser
  • Window > Package manager: browser assets

Packages are categorized in different views. Right next to the "+", you can set the package view to:

  • My assets: download and import your assets here
  • Unity Registry: download and install verified plugins
  • In Project: manage anything installed in the current project

Build A Game

Scene Manager

You need to add your scene in the SceneManager for them to be in the game that will be built.

  • File > Build Settings
  • You may use "Add opened scenes in build"
  • You may drag and drop scenes in the list

πŸͺ² It seems updating Unity will empty the list.

⚠️ Save project settings after changes, e.g., not just the scene.

Unity Editor Modules

To compile to a specific platform, you need to have the required modules installed. Open Unity Hub, navigate to the "Installs" tab, Right-click on your Unity version, and select "Add Modules".

Generate A Build

Navigate to File > Build or File > Build and Run.

Build Configuration

Go to Edit > Project Settings > Player. You can also find the menu in File > Build at the bottom-left button "Player settings...".

  • Set the company name, the product name, the version
  • You may set the icon πŸš€ (and multiple icons for each resolution)
  • You can define the initial configuration
  • In splash image
    • You may remove the unity logo (up to you, or You can move it)
    • Add a splash screen with your own logo
      • First, exit and add your logo to the project files
      • Click on your logo, in texture type, set sprite 2D, and apply
      • Go back to the splash screen
      • Click on "+" and drag and drop your logo inside the field
      • You may set the duration
  • You may set the background too

It's sometimes advised to check Edit > Project Settings > Quality as you may be able to reduce your build size.


Random Notes

Debug Inspector Window

On the top of the inspector window, there are three small dots. You can switch from "normal" to "debug" mode here, which will show you way more fields in the inspector.

Unity Editor Settings

Go to Edit, Then Preferences.

  • General > Disable editor analytics: up to you, more info here
  • General > Editor Theme: Light/Dark

πŸ‘» To-do πŸ‘»

Stuff that I found, but never read/used yet.

  • Selections=Shortcuts to Game Object
  • Tags + Hell
  • PlayerPrefs to save stuff
  • Active Scene and Additive Scenes
  • Game resolution
  • Profiler + IDE debugger
  • Scene templates
  • NavMeshAgent/SetDestination (AI)
  • Static vs Dynamic Game Objects