0% found this document useful (0 votes)
29 views

Final Lecture 1

This document provides an overview of the Unity game engine and environment. It describes Unity as a cross-platform game engine with a user-friendly development environment that includes tools, libraries, and APIs. It also discusses Unity's support for rendering art assets, controlling animations through scripting, creating multiplatform games, and the basic interface components like the Hierarchy, Project, Console, and Scene panels.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Final Lecture 1

This document provides an overview of the Unity game engine and environment. It describes Unity as a cross-platform game engine with a user-friendly development environment that includes tools, libraries, and APIs. It also discusses Unity's support for rendering art assets, controlling animations through scripting, creating multiplatform games, and the basic interface components like the Hierarchy, Project, Console, and Scene panels.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Unity

Lecture 1
What is Unity?
● Unity is a powerful cross-platform game engine and a user-friendly development
environment that provides us with a complete set of tools we can use in our code
quickly and easily.

● Unity application programming interface (API) is filled with useful things such as
commonly used routines, data structures, and classes. These parts of the API are
often called a library.

● Rendering: Unity supports art assets and file formats from 3ds Max, Maya,
Blender, Adobe Photoshop and other graphics programs. These assets can be
added to the game project and managed through Unity's graphical user interface.

● Unity provides a complete set of tools to create characters and objects that your
code can interact with. These assets all live in the project directory as many
separate files or entities that you can control through code. 2
What is Unity?
● Unity provides scene files; 3D models; particle systems for explosions, fire, and
other special effects; and tools to create and edit all of these things.

● To control animations / scene changes in Unity, we use scripting through various


programming languages such as Boo, C#, and JavaScript.

● A game in Unity is made up of many different C# files. Each file can be referred to
as a “class” and end with the .cs file extension (which stands for C Sharp) and
named according to its purpose.

● Multiplatform: Unity supports deployment to multiple platforms. Within a


project, developers have control over delivery to mobile devices, web browsers,
desktops, and consoles.
3
Creating a Project

4
Creating a Project
● If you navigate to the place where you saved your project you will see a directory
with the name of your project and at least three main directories inside (Assets,
Library, and ProjectSettings).

● Assets: It is the root directory for the Unity editor “Project Panel” in which all C#
files, all the things you import, and any other game objects such as 3D models, 2D
textures, and sounds will be saved in this directory. If a file isn’t located in this
directory, your game will not be able to access it.

● ProjectSettings: This directory contains all the settings you have customized for
your project. So, for example, if you set the global gravity setting to be -20 instead
of -9.81, this change will be saved in a file called Physics2DSettings.asset.
5
Interface – Hierarchy Panel
● This window depends on the current scene you
have open, so its contents will look different for
different scenes.

● This is important because the Hierarchy panel is a


list of all the GameObjects (things) currently in
this level.

● In a new scene, we will only have a Main Camera


(2D), Main Camera and Directional Light (3D).

● The create button at the top of the window is used


to create new GameObjects, add effects, add UI,
etc.

● The search bar filters through the list of


6
GameObjects.
Interface – Project Panel
● It shows us the list of all assets (3D models,
scripts, audio files, images, etc.) we create in the
entire project.

● As we create new C# files, they will be shown to us


in the Project view.

● Specifically, the Project panel reflects the Assets/


directory we saw earlier.

● Anything we add to this directory automatically


appears in the Project panel, and any changes you
make to the Project panel changes the Assets/
directory directly. 7
Interface – Project Panel
● To import an asset to the Project
panel, RIGHT CLICK in the Project
panel → Import New Asset.

● The second way is to go through the


menu at the top: Assets → Import
New Asset.

8
Interface – Console Panel
● This view displays all the information that is being created by the C# code we
write.

● Any problems, warnings, and errors will be presented in this panel.

Messages

Warnings
Errors

9
Interface – Inspector Panel
● This panel will display all the information of the
thing you currently have highlighted.

● When you click on a GameObject, you will be shown


all the values and information about this
GameObject.

● The Inspector panel is used to perform a change in


the information of a specific GameObject.

10
Interface – Scene View
● It is a window that is used to explore and edit the game world.

● We can move objects around to place them, scale them, rotate them, or even pan
your own view through the world.

11
Interface – Scene View
● The scene is more like a construction view of the
game that cannot be seen by the player, only you as
the creator of the game can access the scene view.

● There are six buttons to toggle between different


1 2 3 4 5 6
modes (pan, move, rotate, scale, etc.)
1 Pan Button
● Hand (Pan) Button [Q]: this allows navigation of the
2 Translate Button
Scene window. It allows you to drag around in the
Scene window to pan your view. 3 Rotate Button

4 Scale Button
● Translate (Move) Button [W]: this allows to
reposition the selected object using the object’s axis 5 Rect Button

handles. 6 Transform Button 12


Interface – Scene View
● Rotate Button [E]: this is used to rotate the selected
object around each axis

● Scale Button [R]: this is used to adjust the size or


scale of an object via visual handles.
1 2 3 4 5 6
● Rect Button [T]: this also adjusts the size or scale of
an object but in a different way. It mainly used when 1 Pan Button
working with UI.
2 Translate Button
● Transform Button [Y]: this combines all tools. It can
3 Rotate Button
be used to perform translation, rotation, and
scaling for the selected object. 4 Scale Button

● Given that you are not able to see an object selected 5 Rect Button
in the Hierarchy in the Scene window, press the F
key to focus the Scene view on that object.
6 Transform Button 13
Interface – Game View
● The Game panel is the view of the game through the Main Camera.

● Unlike the Scene view, which allows you to explore the game world, the Game view
is a window that previews what the game would look like right now, if you were to
build the game.

14
Interface – Game View
● The Game view is controlled by the Play/Pause/Step
buttons along the top of the Editor.

● It is important to warn that most changes you make to


the hierarchy while in PLAY MODE will NOT be saved
once you leave play mode. 1 2 3

● So, if you play the game and move things around, 1 Play Button

when you unclick PLAY button, things will revert to 2 Pause Button
their original positions.
3 Step Button

● This will result in lost work if you aren’t careful.

15
Game Object
● Game objects are all the “things” that constitute the scene.

● Game objects not only include concrete objects (e.g., a chair in a room), but also
other elements that reside in space such as light sources, audio sources, and
cameras.

● Every game object (even empty ones) has a position and orientation space. Thus,
it can be moved, rotated, and scaled.

● Game objects can be enabled or disabled where disabled objects behave as if they
do not exist.

● It is possible to associate various elements with game objects, called components.

16
Game Object
● To create a blank GameObject, RIGHT
CLICK in the Hierarchy panel and select
“Create Empty”. The object is created
in the Hierarchy named “GameObject”.

● There are several toggles, text fields,


and dropdown menus that are
appeared at the very top of the
Inspector window when the object in
the Hierarchy panel is selected.

● The leftmost toggle enables/disables


the GameObject, effectively turning it
on or off in the Game. 17
Name and Tag
● Name and tag are simply keywords (string) that can be
assigned to a GameObject.

● The text field is the name of the GameObject, currently


called “GameObject”. When we change the name to “Test”
and press ENTER, the name in the Hierarchy should be
changed.

● The dropdown menu lists a number of standard tags defined in Unity, and you can
create new tags of your own.

● Tags describe a type of GameObjects which might be shared by many objects and
help in identifying GameObjects for scripting purposes.
18
Name and Tag
● For example, we might define “Player” tag for player-
controlled characters, an “Enemy” tag for non-player-
controlled characters, items that the player collect in
a Scene with a “Collectable” tag, etc.

● For adding Tag to a GameObject, select the object in


Hierarchy panel → click on the Tag dropdown menu in
Inspector view (it currently says Untagged) → choose one of
the available Tags or click on Add Tag at the bottom to add a
new tag.

19
Components
● Each game object is defined by a collection of associated elements that are called
components which depend on the nature of the object and define its behavior.

● A component is an individual piece of code that does a single thing.

● Unity has several pre-defined components that handle rendering, physics, even
basic character controls.

● We can also define custom components, called scripts, which allow us to create
unique components that do a specific thing and control how the object behaves
and how it reacts to its environment.

● Components that are associated with a GameObject can be viewed and edited in the
Inspector window. 20
Transform Component
● Every GameObject has a component called Transform.

● This component is used to determine and set the


GameObject’s position, rotation, and scale in the game
world.

● Changing these values are the same as using the movement


tools in the Scene view.

21
Adding/Removing Component
● Add Component button in the
Inspector panel is used to assign
components that are pre-defined in
the Unity Engine as well as any
custom scripts (C# files) written in
the project to an object in the scene.

● If the name of the component is


known (which matches the class
name of the script), we can use the
search bar to find it faster.
22
Adding/Removing Component
● To remove a component, right click on the title of the component and select
Remove Component or click on the Cog icon to the right of the component and
choose Remove Component from the dropdown menu.

23
THANK YOU

You might also like