UNITY Lesson 1: Table of Contents
1a: Get Unity; Get Started
1b: Add a Character
1c: An Introduction to Scripting in C#
1d: Uniform Motion in Any Direction
1e: Move To a User-Clicked Location
1f: Background and Falling Rocks

UNITY Lesson 1a:
Get Unity; Get Started

What is Unity?
Unity is a game engine (a software development environment where people create video games).
The video games can be run on the web (and lots of other places).
There's lots more information at Wikipedia and Unity.
Get Unity
There is a free version of Unity (some restrictions apply).
Everything in my lessons can be done with the FREE version.

Go to unity.com to get the latest version.
Download the Unity Hub (which manages all your Unity projects and installations);
the Hub guides you through the rest of the installation.
In particular, you'll need to add a Unity version.

[Data from my install:
January 5, 2020
UnityHubSetup, 58.5 Mb, very quick;
add latest Unity version with Windows-related modules, 2019.2.17f1, download/install took 44 minutes]

My experience getting/using Unity: sometimes it looks like nothing is happening.
Be patient! Look around for a progress bar (which may not be obvious/identifiable until some progress is made).

To uninstall Unity (if you decide not to use it):
Unity User Manual
The searchable Unity User Manual is here. (You may need to switch to a different version.)
Consider bookmarking the user manual for easier future access.
Read it start-to-finish, or use it as a reference.
Open the Unity Hub
You should have a shortcut to the Unity Hub on your desktop; double-click it.
(I delete the desktop shortcut to the specific Unity version: it gets you to the same place, but takes longer.)

desktop shortcut to Unity Hub
Create a New Project
In the Unity Hub, click NEW to create a new project.
  • What template to use?
    Select the 2D (two-dimensional) template.
    (Be careful! It's probably not the default template.)
  • What is the project name?
    Give your project an appropriate name. (My name: ‘Expressions versus Sentences’)
    The name you choose automatically becomes the name of the Main Project Folder
    (where the project is stored on your computer).
  • Where should Main Project Folders be stored on your computer?
    You may want to create your own ‘Unity Projects’ folder in a desired location on your computer.
  • Click Create. It may take a few minutes.
    When finished, your new project will open in the Unity Editor (discussed below).
Note: In these lessons, I use the words ‘project’ and ‘game’ interchangeably.
Note: I may say just ‘Hub’ instead of ‘Unity Hub’.

This shows the ‘Expressions versus Sentences’ project in the Unity Hub.
Click the three vertical dots to the far right of the project
to see some menu items.
FYI: Look at the Main Project Folder on your Computer
When you create a new project in Unity, a Main Project Folder is created on your computer.
The image at right shows the contents of the ‘Expressions versus Sentences’ Main Project Folder that was just created.
How to Delete a Unity Project
If you ever want to delete the ‘Expressions versus Sentences’ project, do the following:
  • In the Unity Hub, click the vertical dots to the far right of the project.
    Choose Remove From List.
    The project will no longer appear in the Hub list, but this does not get rid of the project files on your computer.
  • To get rid of the project files on your computer:
    delete the ‘Expressions versus Sentences’ Main Project Folder on your computer.
    Note: The image at right shows the contents of the Main Project Folder.
    If you want to delete the Main Project Folder, you need to go up one level in the directory structure.

contents of the Main Project Folder
for the ‘Expressions versus Sentences’ project
Unity's Introduction to the Unity Interface (videos: 1 hour)

Unity Editor
Once a project is created, it is available from the Unity Hub. See (1) at right.
Click on the project to open the Unity Editor.
Important Unity Editor Elements
See (2) at right.
  • Toolbar
    The Toolbar has the following groups:
    • Left: tools for manipulating scenes/objects; hover over an icon to get a tool tip
    • Center: play/pause/step controls (for ‘playing’ your game)
    • Right: access to Unity services/account; layers/layout tools
    Above the Toolbar (but not shown at right) is the Main Menu (File, Edit, ...).
  • Scene View and Game View
    Notice the separate tabs for Scene and Game.
    In both Scene and Game views, the scroll wheel can be used to zoom.

    Scene View is your interactive view into the world you are creating.
    In Scene View, you arrange scenery/characters/cameras/lights etc.

    Game View represents your final, published game.
    Game View is rendered from the camera(s) in your game.
    Therefore, you must have one or more cameras, since they control what the player actually sees.

    Keyboard Shortcuts for Scene View and Game View:
    • Scene View: cntl-1
    • Game View: cntl-2
  • Hierarchy Window
    Scenes contain the environments/menus of your game.
    Think of each unique scene file as a unique level.
    A sample scene may be loaded to get you started.

    The Hierarchy Window represents every object in a scene.
    The Hierarchy Window reveals the structure of how objects are related to one another.
    Note: An asterisk (*) appears next to objects with unsaved changes.
  • Inspector Window
    The Inspector Window allows you to view/edit all the properties of a currently-selected object.
  • Project Window
    An asset is any item for use in a project (for example: images, audio files, textures, ...)
    All assets are shown in the Project Window.
    Some assets may come with the template you loaded.
    You can also import assets.
Customizing the Unity Editor
Most everything in the Unity Editor can be moved/resized to make the interface your own:
  • drag tabs to move them
  • drag boundaries to re-size
(The Toolbar can't be customized.)
Toolbar-Layout-Default restores the default layout.

(1) to open a project, click on it in the Unity Hub



(2) important Unity Editor elements in their default layout:
Toolbar
Scene View and Game View
Hierarchy Window
Inspector Window
Project Window
Recovering from Unexpected/Undesirable Behavior
When you first learn a tool, you probably experiment a lot.
If you find yourself saying ‘Eeeekk! What just happened?’ then try the following (in this order):
Unity Asset Store
The Unity Asset Store offers free and to-purchase assets created by Unity Technologies and Unity community members.

The Asset Store is available from the Unity Editor:
  • the ‘Asset Store’ tab in the Scene section
  • Main Menu-Window-Asset Store
If you want more space to browse the store, click Open In Browser (which should appear after you click the Asset Store tab).
Unity ID
You need a Unity ID for the Asset Store.
Your Unity ID also allows you to buy/subscribe to Unity products/services and participate in the Unity community.
Make the game your own!
Next, you'll get a background and character for your game at the Asset Store. By choosing your own (instead of taking my choices), you can make this game your own!
Get a Background for your Game at the Asset Store
I did it this way:
  • refine search: Category-2D; Pricing-Free Assets
  • search for ‘desert’
  • I chose: Free Parallax Desert Background
When you import an asset, you're given the opportunity to preview the files and choose what you want. (I usually take everything.) Be sure to click import after your selections. Large assets may take several minutes to import. See (1a) at right.
How to Delete an Unwanted Asset from your Project
To delete an asset from your project:
  • select its top-level folder in Project-Assets (see (1b))
  • press the keyboard delete key
This action does not remove the asset source file(s) from your computer! It only removes the asset from the current project. See (2) at right.

Usually, you'll want to keep assets on your computer, since they may be useful in other projects. However, if (say) you need to recover disk space, see (3) at right to remove the original asset files from your computer.
How to Inspect Assets
Use the Project Window to explore your assets.
See (4) at right.
Get a Character for your Game at the Asset Store
I did it this way:
  • refine search:
    Category-2D-Characters; Pricing-Free Assets
  • I chose: Jurgen Alexon (2D Free Platformer Char)
Choose a character that comes with some animations (see (5) at right).
Shortly, you'll see how you can preview these animations.
Other Ways to Get Assets Into Your Game
  • Drag files directly from File Explorer into the Project Window. Note: The tooltip changes to a ‘+ inside a square’ when you're in an appropriate place to drop the file(s).
  • Project Window-right click-Import New Asset...
Unity Automatically Saves New Assets Upon Creation
At the completion of this step, you will have folders in Project-Assets corresponding to:
  • your character
  • your background
  • a Scenes folder

Unity automatically saves new assets upon creation. However, subsequent changes to these assets may require a manual save.
Saving All Changes
To save everything after you've made desirable changes,
use Main Menu-File-Save (or keyboard shortcut, cntl-s).

(1a) After importing Free Parallax Desert Background into your project,
a new folder appears in Project-Assets.

(1b) If you subsequently decide to remove this asset from the project,
just delete its top-level folder in Project-Assets (highlighted above).

(2) After importing an asset into your project,
you'll have new folders/files in the Assets subfolder of your Main Project Folder (on your computer).
If you subsequently delete the asset in Project-Assets in the Unity Editor,
then these folders will disappear from your computer.
However, the original asset files are still on your computer (for potential use in other projects).

(3) The original asset files are hidden deep in your computer!
Note: The AppData folder was hidden; I had to ‘show hidden files’ to reveal it.
To completely remove an asset from your computer, delete it here.

(4) A peek inside the Free Parallax Desert Background folder:
when you click on a file (like 1Layer1), details appear in the Inspector window (at right).
Note: The checkered texture indicates transparency (objects behind will show through).

(5) my character comes with some animations
GameObjects
Main Camera
  • SampleScene
    This game has only one scene.
    For me, the default name is SampleScene. See (1a) and (1b) at right.
  • Cameras
    Cameras capture and display your ‘game world’ to the player.
  • Main Camera
    The 2D template comes with an orthographic camera called Main Camera.
    Orthographic means that the camera renders objects uniformly, with no sense of perspective (which is appropriate for a 2D game).
    Main Camera is a GameObject configured in an appropriate way.
  • Delete all GameObjects Except Main Camera
    If you have any GameObject other than Main Camera in SampleScene, delete it now. To delete a GameObject, select it in Hierarchy and press the delete key.
  • Save your Changes
    Get in the habit of saving your changes after you've done something desirable!
  • Argh! What if you lose your Main Camera?
    If something happens and you lose Main Camera, don't despair!
    Here's how to get one that matches what came with the 2D template.
    (Don't worry about what all these mean right now!)
    • Create a new Camera GameObject
      Main Menu-GameObject-Camera
    • Rename
      Select Camera in Hierarchy.
      Click Camera again to rename.
      Type in ‘Main Camera’.
    • In Inspector, change:
      • Tag to MainCamera
      • Transform-Position-Z to $\,-10\,$
      • Camera-Clear Flags to Solid Color
      • Camera-Projection to Orthographic
      • Camera-Depth to $\,-1\,$
    • un-check Inspector-Camera-Occlusion Culling
    • change Inspector-Camera-MSAA to Off
  • Camera Preview
    The ‘Camera Preview’ shows what you would see if you play your game (more on this shortly). Right now, there's nothing in the game—so all you see is background color! See (2) at right.

(1a) You should have only one GameObject in SampleScene: Main Camera.
It has a default icon, as shown here.



(1b) A closer look: you want only Main Camera in SampleScene.
Note: If there is an asterisk (*) next to an item in Hierarchy,
this means there are unsaved changes.




(2) Notice the Camera Preview when Main Camera is selected in Hierarchy.
Right now, there's nothing to see!

Continue with this Unity lesson: Add a Character