Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Introduction to Unity 3D

In this you will learn about the Unity 3D Game Engine and basic elements
of Unity 3D.

Unity is currently the most popular gaming engine used by developers around the
world - and for good reason. It has a powerful visual interface for making games, cross
platform development, and an active contributing community. Unity is a cross-platform
game engine primarily used to develop video games and simulations for PC, consoles,
mobile devices and websites. It is developed by Unity Technologies and was 1st
announced only for OS X, at Apple's Worldwide Developers Conference in the year 2005,
it has since been extended to almost every available platform.

Features of Unity 3D

Here is a list of some of the numerous features of Unity from the technical point of view.
These are:

• Creating and Destroying GameObjects


• Access the Components
• Events for GameObject
• Dealing with Vector Variables and Timing Variables
• Physics Oriented Events
• Coroutine and Return Types

Page 1 of 15
Unity 3D: Interface/Window
As you can see, the main editor window of Unity, you will notice that the window
of Unity 3D is made up of small individual windows that can be rearranged, grouped in
sets, detached from one position and docked back again, within the main window. This
shows that the editor's appearance can differ from project to project and from developer
to developer.

Page 2 of 15
Unity 3D: The Project Window

It will display the library of assets which are available for use and images, music files and
other additional files you will implement in your project. Assets appear here when you
import them within your project.

in Project view, just above the Assets, there is a Favourites section where you can select
and keep items which are frequently used by you.
The Create option in the top-left corner can be used to add new Assets to your project.

Page 3 of 15
Unity 3D: The Scene View
It allows developers to have a visual navigation and editing capability for your
scene, that you are creating. This view has the capability to show a 2D as well as 3D
view, based on the project type you are working on. You can move the obejcts in this view
to position them correctly.

Unity 3D: The Hierarchy Window


It shows a hierarchical representation of each of the available object in the scene. It
reveals the formation of how objects get attached to one another. With the whole Scene
being the Parent Object, the objects added to it becomes the Child object, this concept
is also known as Parenting in Unity world.

Page 4 of 15
Unity 3D: The Inspector Window
It allows developers to inspect and analyze all the editable properties of the selected
object. Since, different objects type has dissimilar sets of properties with varying layout
and contents. For example, when you select an Asset from the project window, the
inspector window will show all the available information about the asset, with the editable
properties available for editing.

Unity 3D: The Toolbar Window


This is the most important window in Unity Editor. On the left, it will contain the primary
tools to manipulate the scene view along with the objects contained within.
The play, pause and step controls will also be available in this Window. You can also
get access to the Unity Cloud Services using the buttons on the right side and the Unity
Account as well, plus visibility menu & the editor layout menu that will provide some
alternating layout for editor-windows.

Basically, the toolbar does not come under window category.

Unity 3D: The Game View


In this window the actual Game view is rendered from the camera in the game. This allows
you to check how the actual game view will look like.

Page 5 of 15
Game Project Elements of Unity 3D
There is set of elements (or components) which together forms a Game, developed using
Unity engine. These elements play a major role in making the game interactive as well as
in adding features that can vividly express your Game's objective. Let's discuss about
these elements and their functionality.

Assets
Assets are the representation of project item(s) which you can implement in your game
or project. An asset can be a file imported from outside of Unity, like the 3D model, audio
and sound file, images (jpeg, gif, png etc), textures or any of the other file types which is
supported by Unity. There is also a collection of asset-types which can be produced within
Unity.

Examples of such assets are:

• Animator Controller
• Audio Mixer
• Render Texture
• Pictures
• Animation files

Page 6 of 15
The Project
Project in Unity is a folder or location which holds your complete game project along with
all its associated assets which may contain the library and assets sub-folder also.

Packages
It is a precompiled cluster of game assets. Unity comes with various packages.

GameObject
Every object present within the game is a GameObject. Technically, they don't append
any functionality to your game project but merely acts as holders for components like
the Transform, Light, Script, and RigidBody components. You will learn about them in
the coming chapters, with practical implementation in the form of small projects.

Components
Components are the basic building blocks i.e. the nuts & bolts of objects and their
activities in a game. They act as functional pieces for each GameObject. By default, every
GameObjects have a Transform Component set automatically, because, it dictates
where the GameObject is positioned within the Unity environment, and how it gets rotated
and scaled.

Scenes
A Scenes can be defined as the base or the parent object, where you can place your
GameObjects to make a level of the game. One or more scenes (aka, levels) are generally
put into a game and they are linked together, which your audience will cross or pass by
clearing some specific objectives. All these objectives and the logic of the game will be
put in methods which will run along with the player within the scene.

Page 7 of 15
Prefab
Prefabs are the reusable GameObject components which are laid up in the Project View
window. Prefabs can be introduced into any number of scenes, as many times as you
want, per scene. You can create instance of these prefabs which are linked to the main
Prefab. It doesn't matter how many instances exist in your project; when you do any
changes to the Prefab, you can visualize the change applied to all other instances. You
will work with prefabs in the later chapters, while developing small game projects.

Build
It is an exported adaptation of your game that will contain all the essential scenes for
playback on the specific platform.

Page 8 of 15
Creating First Project with Unity 3D
You must be pretty excited to get started with making games! Let's not wait any further,
and fire up Unity. The first thing you should see, after the splash screen, is this:

If you see this screen, simply click on the Projects tab on the upper left.

Page 9 of 15
Click on New Project and you should see the following screen.

Page 10 of 15
You can give your project a name by entering it in the field marked 1 and you can choose
where the project is stored on your computer by clicking on the three dots marked 2.
Now, since we'll be dealing with 2D game design in this series, we'll go ahead and click
on the radio button saying 2D at the field marked 3. This informs Unity that we want to
work on 2D games, so it sets up our base project accordingly. Click on the button Create
Project, and let's roll! We're making our first game.

Exploring What You See

Page 11 of 15
The field we have marked 1 is called the Hierarchy. It's where you will be
adding objects, cameras, light sources and stuff like that in your scene. We will explain
more on scenes and projects later on.
Next we have field number 2. This is where the Assets of your game are stored. Assets
are all the external resources that your game uses. This includes images, fonts, scripts,
scenes, text files, XML files, music, sounds, videos etc.
Field number 3 is the Scene View. It's where you'll see what's actually going on in the
scene itself. You'll also be adding your assets in here, dragging them around, making
changes, all in the Scene View.
At 4, we have the Inspector. This is where you'll modify, add and remove components
and the properties of the objects that you add in the scene. It looks empty now, but we'll
get to that soon.
Number 5 is a set of Play Buttons. These buttons are used for starting up your game in
the editor, so you can test your work. You don't even have to worry about the game
crashing in case of an error, Unity will stop gameplay as soon as it encounters an error,
that it cannot handle.
And, at number 6, we have the Console Tab. If you're familiar with programming, you'll
know that all the output messages, errors, warnings and debug messages are shown
here. It's quite the same thing for Unity, except output messages are done a bit differently
than you think.

Page 12 of 15
Adding and Managing Assets in
Unity 3D
We see that our game looks pretty empty right now. So, let's fix that. Grab an image that
you would want to make your player. For example, we will be using this happy little star.
We have Mr. Star here on our Desktop so that we can easily access him. To add him
into Unity, we will simply drag and drop the image into our Assets.

What we've done so far is just added the Star image into our project, but not into the
current scene. To add it into the scene, just drag and drop the image from the Assets
view into either the Scene View or the Hierarchy (Objects added in the Scene View get
added to the Hierarchy automatically).
Objects that you add as images are stored as sprites when you're working in
2D. Sprites is Unity's way of remembering that you're using these images to work with
them in 2 dimensions, not 3.

Page 13 of 15
You've added just one image, and you already must have noticed quite some changes in
different views in the Unity window. First of all, and what may seem to be most noticeable,
is that the Inspector View is no longer empty with options such as, Sprite
Renderer and Transform listed below. These are called Components and they're
important.

You see, Transform is a property of any object in Unity which stores some of its most
basic data. What falls under basic data?

• Every object has a Position.


• It has a Rotation angle.
• It has a Scale Factor.

These are the values which tell Unity where and how exactly an object is positioned in
the game world. Try changing the X, Y and Z elements of these properties to different
values to see what happens.
Sprite Renderer is a component which works with how your sprite (that is, your image)
is handled on-screen. It has a few properties like the image to render, the color of the
image (white means the image is unmodified), flips, and sorting layers. For now, we
don't want to change anything around in the Sprite Renderer, so let's leave it as it is.
If you click the Play button now, you'll see that the image you added is now visible in-
game! Woohoo! But there's a blue background that you don't quite recall adding. That's
because that background is added by the Camera in the scene. If you want to change
that background color, simply click on the Main Camera in the Hierarchy, and then
change the background color by clicking on the Background property for the Camera
component in the Inspector.

Page 14 of 15
So far, we've only added one asset. But as your project grows and gets bigger, and you
add more and more assets, it may get difficult to manage all your assets. That's why
making sure your assets are properly organized from the start reduces a lot of future
headaches (Trust me, I've been a victim).

You can organize your assets into folders, right click anywhere in the Assets section, and
select, Create → Folder.

Page 15 of 15

You might also like