hh i d i i Enter the Third Dimension

sandpaperleadΛογισμικό & κατασκευή λογ/κού

31 Οκτ 2013 (πριν από 4 χρόνια και 12 μέρες)

125 εμφανίσεις

Rise Group
Chapter 1.
h hi d i i
Enter t
h
e T
hi
r
d
D
i
mens
i
on
Unity 3.x Game Development Essentials, Will Goldstone, PACKT, 2011
• This chapter will introduce you to the concepts
of working in 3D and how game development
works with Unity.

Having covered how 3D development works
Having

covered

how

3D

development

works
,
you will learn the core windows that make up
the Unity Editor environment
the

Unity

Editor

environment
.
Rise Group
2
Contents
1.1 Getting to grips with 3D
1.2 Rigidbody physics
1 3 Essential Unity concepts
1
.
3

Essential

Unity

concepts
1.4 The interface
1 5 S
1
.
5

S
ummary
Rise Group
Rise Group
3
• As Unity is primarily a 3D-based development tool,
h h hi b k ill
many concepts t
h
roug
h
out t
hi
s
b
oo
k
w
ill
assume a
certain level of understanding of 3D development and
game engines
game

engines
.

,W LV FUXFLDO WKDW\RX HTXLS\RXUVHOI ZLWK DQ

,W
?
LV
?
FUXFLDO
?
WKDW
?
\RX
?
HTXLS
?
\RXUVHOI
?
ZLWK
?
DQ
?
XQGHUVWDQGLQJ?RI?WKHVH?FRQFHSWV?EHIRUH?GLYLQJ?LQWR?
WKH?
S
UDFWLFDO?HOHPHQWV?RI?WKH?UHVW?RI?WKLV?ERRN??
S
• As such
,
in this cha
p
ter
,
we'll make sure
y
ou're
,p,y
prepared by looking at some important 3D concepts
before moving on to discuss the concepts and
f f f
Rise Group
inter
f
ace o
f
Unity itsel
f
.
4
• You will learn about :
– Coordinates and vectors
– 3D shapes
– Materials and textures

5L
J
LGERG
\
G
\
QDPLFV
J\
\
– Collision detection

*DPH2E
M
HFWV DQG?&RP
S
RQHQWV
M
S
– Assets and Scenes

3UHIDEV
– Unity editor interface
Rise Group
5
1.1 Gettin
g
to
g
ri
p
s with 3D
g g p
• Coordinates
• Local space versus world space

Vectors
Vectors

• Cameras
P j ti d
3D 2D

P
ro
j
ec
ti
on mo
d
e –
3D
versus
2D
• Polygons, edges, vertices, and meshes
• Materials, textures, and shaders
Rise Group
6
Coordinates
• Coordinates

=?D[LV?IRU?GHSWK??
– X-axis for horizontal
Y
axis for vertical

<
?
D[LV
?
IRU
?
YHUWLFDO
• In 3D applications, you'll see information on objects
laid out in X,Y,Z format
-
this is known as the
laid

out

in

X,

Y,

Z

format

this

is

known

as

the

Cartesian coordinate method.
• Dimensions
,
rotational values
,
and
p
ositions in the 3D
,,p
world can all be described in this way.
• In the book, as in other documentation of 3D, you'll
see such information written with parenthesis, shown
as follows: (3, 5, 3)
Rise Group
7
• In the following image, a cube is shown at location (3,5,3) in the
3D world meaning it is 3 units from 0 in the X
axis 5 up in the
3D

world
,
meaning

it

is

3

units

from

0

in

the

X
-
axis
,
5

up

in

the

Y-axis, and 3 forward in the Z-axis:
Rise Group
8
Local s
p
ace versus world s
p
ace
p p
• A crucial concept to begin looking at is the difference
b l l d ld
b
etween
l
oca
l
space an
d
wor
ld
space.
ld h i i f i i f
• In every 3D wor
ld
, t
h
ere
i
s a po
i
nt o
f
or
i
g
i
n, o
f
ten
referred to as the 'origin' or 'world zero', as it is
represented by the position (0 0 0)
represented

by

the

position

(0
,
0
,
0)
.

$OO ZRUOG SRVLWLRQV RI REMHFWV LQ?'DUH UHODWLYH WR

$OO
?
ZRUOG
?
SRVLWLRQV
?
RI
?
REMHFWV
?
LQ
?
?'
?
DUH
?
UHODWLYH
?
WR
?
ZRUOG?]HUR??
Rise Group
9
• However, to make things simpler, we also use local space
(also known as object space) to define object positions in
(also

known

as

object

space)

to

define

object

positions

in

relation to one another.

7KHVH UHODWLRQVKLSV DUH NQRZQ DV SDUHQW
FKLOG UHODWLRQVKLSV

7KHVH
?
UHODWLRQVKLSV
?
DUH
?
NQRZQ
?
DV
?
SDUHQW
?
FKLOG
?
UHODWLRQVKLSV
??
• In Unity, parent-child relationships can be established easily
b d i bj t t th i th Hi h
b
y
d
ragg
i
ng one o
bj
ec
t
on
t
o ano
th
er
i
n
th
e
Hi
erarc
h
y.
• This causes the dra
gg
ed ob
j
ect to become a child
,
and its
gg j,
coordinates from then on are read in terms relative to the
parent object.
• For example, if the child object is exactly at the same world
position as the parent object, its position is said to be
(0,0,0),even if the parent position is not at world zero.
Rise Group
(0,0,0),

even

if

the

parent

position

is

not

at

world

zero.
10
• The first diagram (i) shows two
bj t i ld
o
bj
ec
t
s
i
n wor
ld
space.
– A large cube exists at
coordinates(3,3),
coordinates(3,3),

– and a smaller one at coordinates
(6,7).
• In the second diagram (ii), the
smaller cube has been made a
smaller

cube

has

been

made

a

child object of the larger cube.

$V?VXFK?WKH?VPDOOHU?FXEH V?
FRRUGLQDWHV?DUH?VDLG?WR?EH????????
EHFDXVH?LWV?]HUR?SRLQW?LV?WKH?ZRUOG?
SRVLWLRQ RI WKH SDUHQW
Rise Group
position

of

the

parent
.
11
Vectors
• You'll also see 3D vectors described in Cartesian
coordinates
coordinates
.
• Like their 2D counter
p
arts
,
3D vectors are sim
p
l
y

p,p y
lines drawn in the 3D world that have a direction
and a length.
• Vectors can be moved in world space, but remain
unchan
g
ed themselves.
g
• Vectors are useful in a game engine context, as they
allow us to calculate distances relative angles
allow

us

to

calculate

distances
,
relative

angles

between objects, and the direction of objects.
Rise Group
12
Cameras
• Cameras are essential in the 3D world, as they act
as the viewport for the screen
as

the

viewport

for

the

screen
.

Cameras can be placed at any point in the world,
Cameras

can

be

placed

at

any

point

in

the

world,

animated, or attached to characters or objects as
part of a game scenario.
• Many cameras can exist in a particular scene, but
it is assumed that a single main camera will always
it

is

assumed

that

a

single

main

camera

will

always

render what the player sees.
• This is why Unity gives you a Main Camera object
whenever you create a new scene.
Rise Group
13
Pro
j
ection mode - 3D versus 2D
j
• The Projection mode of a camera states whether it renders in 3D
(Perspective) or 2D (Orthographic)
(Perspective)

or

2D

(Orthographic)
.
• Ordinaril
y,
cameras are set to Pers
p
ective Pro
j
ection mode
,
and as
y,p j,
such have a p
y
ramid shaped Field of View (FOV).
• A Perspective mode camera renders in 3D and is the default
Projection mode for a camera in Unity
Projection

mode

for

a

camera

in

Unity
.
Rise Group
14
• Cameras can also be set to Orthographic Projection mode in
order to render in 2D
these have a rectangular field of view
order

to

render

in

2D
-
these

have

a

rectangular

field

of

view
.
• This can be used on a main camera to create com
p
lete 2D
g
ames
p g
or simpl
y
used as a secondar
y
camera used to render Heads Up
Display (HUD) elements such as a map or health bar.
Rise Group
15
Pol
yg
ons, ed
g
es, vertices, and meshes
yg g
• In constructing 3D shapes, all objects are ultimately made up of
interconnected 2D shapes known as
polygons
joufsdpoofdufe

E

tibSft

lopZo

bt

polygons
.
• On importing models from a modeling application, Unity converts
all polygons to polygon triangles.
• B
y
combinin
g
man
y
linked pol
yg
ons, 3D modelin
g
applications
allow us to build complex shapes, known as meshes.

3RO\JRQ WULDQJOHV?DOVR UHIHUUHG WR DV IDFHV?DUH LQ WXUQ PDGH XS

3RO\JRQ
?
WULDQJOHV
?
?DOVR
?
UHIHUUHG
?
WR
?
DV
?
IDFHV?
?
DUH
?
LQ
?
WXUQ
?
PDGH
?
XS
?
RI?WKUHH?FRQQHFWHG?edges.
• The locations at which these
ed
g
es meet are known as
points or vertices.
Rise Group
16
• Game engines are able to make calculations regarding the points
of impact known as collisions when using complex collision
of

impact
,
known

as

collisions
,
when

using

complex

collision

detection with Mesh Colliders.
• Mesh can be used to specify a shape for collision that is less
detailed than a visible ob
j
ect, but rou
g
hl
y
the same shape.
• This can help save performance as the physics engine needn't
check a mesh in detail for collisions.
check

a

mesh

in

detail

for

collisions.
Rise Group
17
Object Mesh Collider Mesh
Materials, textures, and shaders
• Materials are a common concept to all 3D applications, as they
provide the means to set the visual appearance of a 3D model
provide

the

means

to

set

the

visual

appearance

of

a

3D

model
.
• From basic colors to reflective image-based surfaces, materials
handle everything.
• In Unity, the use of materials is easy.
• Any materials created in your 3D modeling package will be
imported and recreated automaticall
y
b
y
the en
g
ine and created
as assets that are reusable.
• You can also create
y
our own materials from scratch, assi
g
nin
g

y g g
ima
g
es as textures and selectin
g
a shader from a lar
g
e librar
y

that comes built-in.
• You ma
y
also write
y
our own shader scri
p
ts or co
py
-
p
aste those
y y
p py
p
written b
y
fellow developers in the Unit
y
communit
y
,
g
ivin
g

y
ou
more freedom for expansion beyond the included set.
Rise Group
18
1.2 Ri
g
idbod
y
p
h
y
sics
g y
p y
• For developers working with game engines, physics
i id i f i l i
eng
i
nes prov
id
e an accompany
i
ng way o
f
s
i
mu
l
at
i
ng
real-world responses for objects in games.
• In Unity, the game engine uses Nvidia's PhysXengine,
a popular and highly accurate commercial physics
a

popular

and

highly

accurate

commercial

physics

engine.
Rise Group
19
Collision detection
• By giving an object a Collider component, we are effectively
placing an invisible net around it
placing

an

invisible

net

around

it
.
• This net usuall
y
mimics its sha
p
e and is in char
g
e of re
p
ortin
g

y p g p g
an
y
collisions with other colliders, makin
g
the
g
ame en
g
ine
respond accordingly.
• There are two main types of Collider in Unity.
Rise Group
20
1.3 Essential Unit
y
conce
p
ts
y p
• The Unity way - an example
• Assets

Scenes
Scenes

• GameObjects
C t

C
omponen
t
s
• Scripts
• Prefabs
Rise Group
21
• Unity makes the game production process simple by giving you a
set of logical steps to build any conceivable game scenario
set

of

logical

steps

to

build

any

conceivable

game

scenario
.
• Renowned for bein
g
non-
g
ame-t
yp
e s
p
ecific
,
Unit
y
offers
y
ou a
g
g
yp p,y y
blank canvas and a set of consistent procedures to let
y
our
imagination be the limit of your creativity.
• By establishing its use of the GameObject concept, you are able
to break down parts of your game into easily manageable objects,
which are made of man
y
individual Component parts.

%\PDNLQJ LQGLYLGXDO REMHFWV ZLWKLQ WKH JDPH
?
LQWURGXFLQJ

%\
?
PDNLQJ
?
LQGLYLGXDO
?
REMHFWV
?
ZLWKLQ
?
WKH
?
JDPH
?
?
LQWURGXFLQJ
?
IXQFWLRQDOLW\?WR?WKHP?ZLWK?HDFK?FRPSRQHQW?\RX?DGG??\RX?DUH?DEOH?
WR?LQILQLWHO\?H[SDQG?\RXU?JDPH?LQ?D?ORJLFDO?SURJUHVVLYH?PDQQHU?
Rise Group
22
• Component parts in turn have Variables - essentiall
y
properties
of the component, or settings to control them with.

By adjusting these
variables
,you
'
ll have complete control over
By

adjusting

these

variables
-

\pv mm

ibwf

dpnSmfuf

dpouspm

pwfs

uif fggfdu uibu Component has on your object.
• The following diagram illustrates this:
Rise Group
23
• In the following image we can see a Game Object with a Light
Component
as seen in the Unity interface:
Bnlonmdms
,
as

seen

in

the

Unity

interface:

Rise Group
24
The Unit
y
wa
y
- an exam
p
le
y y
p
• If we wished to have a bouncing ball as part of a game, then we would
execute the next steps
– GameObject>CreateOther>Cube
• This menu will give you a new GameObject with a Sphere mesh
• Unity will automatically add a Renderer component to make it visible.

&RPSRQHQW!3K\VLFV!5LJLGERG\
• We can then add a Rigidbody component. (A Rigidbody is a component which tells
Unity to apply its physics engine to an object. )

:LWK WKLV FRPHV SURSHUWLHV VXFK DV PDVV JUDYLW\GUDJ HWF

:LWK
?
WKLV
?
FRPHV
?
SURSHUWLHV
?
VXFK
?
DV
?
PDVV
??
JUDYLW\
??
GUDJ
?
HWF
?
• Our sphere will now fall to the ground when the game runs, but how do we make it
bounce?

*DPH2EMHFW
!
&UHDWH2WKHU
!
3ODQH
*DPH2EMHFW
&UHDWH2WKHU
3ODQH
• We have to make a plane to show that the ball is bouncing.
– Setting the Physics Material Variable of Sphere Collider Component

We need to set this variable to have a bouncing ball.
We

need

to

set

this

variable

to

have

a

bouncing

ball.
• This is a setting for the physics engine, defining how it will react to other objects'
surfaces.
• Setting Method
Cli k th i ht b tt th P j t Vi
Rise Group

Cli
c
k

th
e r
i
g
ht
mouse
b
u
tt
on on
th
e
P
ro
j
ec
t

Vi
ew
– Import Package > Physic Materials
– Drag the Bouncy element of the imported Physic Materials to the Physics Material
– Try also the other elements : Ice, Metal, Rubber, Wood and compare the results
25
Rise Group
26
• This streamlined approach for the most basic of tasks,
h h i l d i fi
suc
h
as t
h
e prev
i
ous examp
l
e, seems pe
d
estr
i
an at
fi
rst.
ll fi d h b l i hi
• However, you'
ll
soon
fi
n
d
t
h
at
b
y app
l
y
i
ng t
hi
s
approach to more complex tasks, they become very
simple to achieve
simple

to

achieve
.

+HUH LV DQ RYHUYLHZ RI VRPH IXUWKHU NH\8QLW\

+HUH
?
LV
?
DQ
?
RYHUYLHZ
?
RI
?
VRPH
?
IXUWKHU
?
NH\
?
8QLW\
?
FRQFHSWV?\RX OO?QHHG?WR?NQRZ?DV?\RX?JHW?VWDUWHG??
Rise Group
27
Assets
• These are the building blocks of all Unity projects.
• From textures in the form of image files, through 3D
d l f h d d fil f ff i
mo
d
e
l
s
f
or mes
h
es, an
d
soun
d

fil
es
f
or e
ff
ects, Un
i
ty
refers to the files you'll use to create your game as
assets
assets
.

7KLV LV ZK\LQ DQ\8QLW\SURMHFW IROGHU DOO ILOHV XVHG DUH

7KLV
?
LV
?
ZK\
?
LQ
?
DQ\
?
8QLW\
?
SURMHFW
?
IROGHU
?
DOO
?
ILOHV
?
XVHG
?
DUH
?
VWRUHG?LQ?D?FKLOG?IROGHU?QDPHG?$VVHWV??
• This Assets folder is mirrored in the Project panel of
the Unity interface
Rise Group
the

Unity

interface
28
Im
p
ort Packa
g
e
(
Assets
)
p g ( )
Rise Group
29
Asset Store
Rise Group
30
Scenes
• In Unity, you should think of scenes as individual levels,
f
or areas o
f
game content.
i i h ll b
• B y c o n s t r u c t
i
ng your game w
i
t
h
many scenes, you'
ll

b
e
able to distribute loading times and test different parts
of your game individually
of

your

game

individually
.

$Q\FXUUHQWO\RSHQ VFHQH LV ZKDW\RX DUH ZRUNLQJ RQ

$Q\
?
FXUUHQWO\
?
RSHQ
?
VFHQH
?
LV
?
ZKDW
?
\RX
?
DUH
?
ZRUNLQJ
?
RQ
??
DV?QR?WZR?VFHQHV?FDQ?EH?ZRUNHG?RQ?VLPXOWDQHRXVO\??
• Scenes can be manipulated and constructed by using
the Hierarchy and Scene views.
Rise Group
the

Hierarchy

and

Scene

views.
31
GameObjects
– Any active object in the currently open scene is called a GameObject.
– Certain assets taken from the Project panel such as models and prefabs
b bj h l d ('i i d') i h
b
ecome
g
ame o
bj
ects w
h
en p
l
ace
d

(
or
'i
nstant
i
ate
d')

i
nto t
h
e current
scene.

2WKHU?RE
M
HFWV?VXFK?DV?
S
DUWLFOH?V
\
VWHPV?DQG?
S
ULPLWLYHV?FDQ?EH?
S
ODFHG?LQWR?
M S\S S
WKH?VFHQH?E\?XVLQJ?WKH?Create button on the Hierarchy or by using the
GameObject menu at the top of the interface.
All
GameObjects
contain at least one
component
up cfhjo Zjui uibu jt

$OO
?
*DPH2EMHFWV
FRQWDLQ
?
DW
?
OHDVW
?
RQH
?
component
up

cfhjo

Zjui
-
uibu

jt
-
uif Transform component.
• Transform simply tells the Unity engine the position, rotation, and scale of an object
Rise Group
32
Com
p
onents
p
• Components come in various forms.
Th b f ti b h i d fi i

Th
ey can
b
e
f
or crea
ti
ng
b
e
h
av
i
or,
d
e
fi
n
i
ng appearance,
and influencing other aspects of an object's function in
the game
the

game
.
• By attaching components to an object, you can
immediately apply new parts of the game engine to
immediately

apply

new

parts

of

the

game

engine

to

your object.
• Common com
p
onents of
g
ame
p
roduction come built-
p g p
in with Unity, such as the rigidbody, lights, cameras,
particle emitters, and more.
• To build further interactive elements of the game,
you'll write scripts, which are also treated as
components in Unity
Rise Group
components

in

Unity
.
33
Scri
p
ts
p
• While being considered by Unity to be components, scripts
are an essential part of game production,and deserve a
are

an

essential

part

of

game

production,

and

deserve

a

mention as a key concept.
• Unity Script

C Sharp
-bwbtdsjSu
Cpp Cvu jo uijt dpvstf Zf Zjmm vtf D

C

Sharp
,
Javascript
,
Boo

(But

in

this

course

we

will

use

C#)
• The beauty of using Unity scripting is that any script you
write for your game will be straightforward enough after a
few examples as Unity has its own built
-
in Behavior class
few

examples
,
as

Unity

has

its

own

built
in

Behavior

class

called Monobehaviour - a set of scripting instructions for
you to call upon.

7R ZULWH VFULSWV\RX

OO XVH 8QLW\

V VWDQGDORQH VFULSW HGLWRU

7R
?
ZULWH
?
VFULSWV
??
\RXOO
?
XVH
?
8QLW\V
?
VWDQGDORQH
?
VFULSW
?
HGLWRU
??
Monodevelop.
• You may also designate your own script editor in the Unity
preferences if you wish to such as Visual Studio
preferences

if

you

wish

to
,
such

as

Visual

Studio
.
Monodevelop is recommended however, as it offers auto-
completion of code as you type and is natively developed
and updated by Unity Technologies
Rise Group
and

updated

by

Unity

Technologies
.
34
Prefabs
• Unity's development approach hinges around the
G Obj
b i l h l
G
ame
Obj
ect concept,
b
ut
i
t a
l
so
h
as a c
l
ever way to
store objects as assets to be reused in different parts
of your game and then instantiated (also known as
of

your

game
,
and

then

instantiated

(also

known

as

'spawning' or 'cloning') at any time.
• By creating complex objects with various components
and settin
g
s
,

y
ou'll be effectivel
y
buildin
g
a tem
p
late
g,y y g p
for something you may want to spawn multiple
instances of (hence 'instantiate'), with each instance
h b i i di id ll difi bl
t
h
en
b
e
i
ng
i
n
di
v
id
ua
ll
y mo
difi
a
bl
e.
Rise Group
35
Prefab Exam
p
le
p
• Use the example with the bouncing ball.

Click the right mouse button to create the prefab on the Project Panel
Click

the

right

mouse

button

to

create

the

prefab

on

the

Project

Panel

(Create > Prefab)
Rise Group
36
• Rename the New Prefab to Bouncin
g
Ball Prefab

'UDJ WKH 6SKHUH RQ WKH +LHUDUFK\3DQHO WR WKH %RXQFLQJ %DOO

'UDJ
?
WKH
?
6SKHUH
?
RQ
?
WKH
?
+LHUDUFK\
?
3DQHO
?
WR
?
WKH
?
%RXQFLQJ
?
%DOO
?
3UHIDE??7KH?DWWULEXWHV?RI?WKH?VSKHUH?ZLOO?EH?FRSLHG?WR?WKH?SUHIDE?
SHU?WKLV?SURFHVV?
Rise Group
37
• When
y
ou dra
g
the Bouncin
g
Ball Prefab which is on the Pro
j
ect
Panel, to the Hierarchy Panel, a new game object is instantiated.
• Be carefull!! Whenever you instantiate a new game object, the
new instantiated game object have the same initial positions, so
y
ou have to translate the positions.
Rise Group
38

Instantiate the third Game Object (Bouncing Ball) by dragging the

Instantiate

the

third

Game

Object

(Bouncing

Ball)

by

dragging

the

Bouncing Ball Prefab on the Project Panel to the Hierarchy Panal.
Rise Group
39
• Execute the program

Show if the three balls are all bouncing
Show

if

the

three

balls

are

all

bouncing
• Change the Physic Material of the game objects which
a
r
e

ge
n
e
r
ated

by

t
h
e
Pr
e
f
ab,

a
n
d

co
m
pa
r
e

t
h
e
r
esu
l
t
a e ge e ated by t e e ab,a d co pa e t e esu t
Rise Group
40
1.4 The interface
• The Scene view and Hierarch
y

y
– Control tools
Control bar

&RQWURO
?
EDU
?
– Search box

&UHDWH?EXWWRQ?
• Th
e
In
specto
r
e specto
• The Project window
• The Game view
Rise Group
41
• The Unity interface, like many other working
i h i bl l
e n v
i
ronments,
h
as a custom
i
za
bl
e
l
ayout.
Rise Group
42
• Scene [1]—where the game is constructed.
• Game [2]—the preview window, active only in play mode.

+LHUDUFK\>?@
??
D OLVW RI
*DPH2EMHFWV
LQ WKH VFHQH

+LHUDUFK\
?
>?@
??
D
?
OLVW
?
RI
?
*DPH2EMHFWV
LQ
?
WKH
?
VFHQH
??
• Project [4]—a list of your project's assets; acts as a library.
• Inspector [5]—settings for currently selected asset/object/setting.
Hierarchy
Panel
Scene View
Panel
Inspector
Project
Panel
Game View
Rise Group
43
The Scene view and Hierarch
y
y
• The Scene view is where you will build
the entirety of your game project in
the

entirety

of

your

game

project

in

Unity.
• This window offers a perspective (full 3D)
view, which is switchable to ortho
g
raphic
(top-down, side-on, and front-on) views.
Window>Layouts>2by3
• Dragging an asset to this window (or the
Hierarchy) will create an instance of it as
a
GameObject
in the Scene
a

GameObject
in

the

Scene
.
• The Scene view is tied to the Hierarchy,
which lists all GameOb
j
ects in the
j
currentl
y
open scene in ascendin
g

alphabetical order.
Rise Group
44
Window>Layouts>4 Split
Control tools
• The Scene window is also accompanied by four useful control tools.
(Accessible from the keyboard using keys Q, W, E, and R )

The Hand tool [
Q]:

The

Hand

tool

[
Q]:

– This tool allows navigation of the Scene window.
– By itself, it allows you to drag around in the Scene window with the left
mouse button to pan your view
mouse

button

to

pan

your

view
.
– Holding down Alt with this tool selected will allow you left click to orbit
your view around a central point you are looking at.

+ROGLQ
J
?WKH?$OW?NH
\
?ZLWK?UL
J
KW?FOLFN?ZLOO?DOORZ?
\
RX?WR?]RRP
?
?DV?ZLOO?
J\J\?
VFUROOLQ
J
?WKH?PRXVH?ZKHHO?
• The Translate tool [W]:

Selectin
g
ob
j
ects either in the Hierarch
y
or Scene means
y
ou'll be able to
g j y y
dra
g
the ob
j
ect's axis handle in order to reposition them.
• The Rotate tool[E]:

rotate
y
our ob
j
ect around each axis.
y j
• The Scale tool [R]:
– It adjusts the size or scale of an object using visual handles.
Rise Group
45
Q, W, E, R
• Having selected objects in either the Scene or
Hi h h i di l l d i b h
Hi
erarc
h
y, t
h
ey
i
mme
di
ate
l
y get se
l
ecte
d

i
n
b
ot
h
.
i h b bl bj
• G
i
ven t
h
at you may not
b
e a
bl
e to see an o
bj
ect
you've selected in the Hierarchy in the Scene window,
– Unity also provides the use of the F key, to focus your Scene
view on that ob
j
ect.
j
• Simply select an object from the Hierarchy, hover your mouse cursor over
the Scene window, and press F.
– You can also achieve this by double-clicking the name of a
game object in the Hierarchy.
Rise Group
46
Control bar
• In addition to the control tools, there is also a bar of additional
options to help you work with your Unity scenes, which is shown
f ll
as
f
o
ll
ows:
– Draw mode (default is 'Textured')

5HQGHU?PRGH??GHIDXOW?LV? 5*% ??
– Toggle scene lighting
– Toggle overlays : shows and hides GUI elements and Skyboxes and
toggles the 3D grid
– Toggle audition mode : previews audio sources in the current scene
– Gizmos : use this pop-out menu to show or hide Gizmos, the 2D
i f li h d h h i h
Rise Group
i
cons o
f
cameras,
li
g
h
ts, an
d
ot
h
er components s
h
own
i
n t
h
e scene.
47
Search box
• While the Scene view is intrinsically linked with the Hierarchy,
often
y
ou ma
y
need to locate an item or t
yp
e of item in the
y y yp
Scene view itself b
y
searchin
g
.
• Simply type the name or data type of an object into the search,
and the Scene view will grey out other objects in order to
and

the

Scene

view

will

grey

out

other

objects

in

order

to

highlight the item you have searched for.
Rise Group
48
Create button
• As many of the game
assets
y
ou'll use in Unit
y

y y
will be created b
y
the
editor itself, the Hierarchy
has a Create button that
ll
a
ll
ows
y
ou to create
objects that are also
located within the top
G Obj t
G
ame
Obj
ec
t
menu.
• Similar to the Create
button on the Pro
j
ect
panel, this drop-down
menu creates items and
immediatel
y
selects them
so that you may rename or
begin working with them in
h S I
Rise Group
t
h
e
S
cene or
I
nspector.
49
The Ins
p
ector
p
• The Inspector is a
toolkit to adjust every
toolkit

to

adjust

every

element of any
GameObject or asset
i j t
i
n
y
our pro
j
ec
t
.

The Inspector will
The

Inspector

will

show every
component part of
anything you select
anything

you

select
.
Rise Group
50
• In this image, the Inspector is showing
properties for a
target
pcMfdu jo uif
SspSfsujft

gps

b

target
pcMfdu

jo

uif

hbnf
• The object itself features two
components
Transform and
components
-
Transform

and

Animation.
• The Inspector will allow you to make
chan
g
es to settin
g
s in either of them.
• Also note that in order to temporarily
disable any component at any time
disable

any

component

at

any

time
,
which will become very useful for
testing and experimentation.
Y i l d l h h kb

Y
ou can s
i
mp
ly

d
ese
l
ect t
h
e c
h
ec
kb
ox
to the left of the component's name.
• Likewise
,
if
y
ou wish to switch off an
,y
entire object at a time, then you may
deselect the checkbox next to its name
at the top of the Inspector window
Rise Group
at

the

top

of

the

Inspector

window
.
51
The Pro
j
ect window
j
• The Project window is a direct view
of the Assets folder of your project
of

the

Assets

folder

of

your

project
.
• Every Unity project is made up of
a parent folder, containing three
subfolders - Assets, Librar
y
, and
while the Unity Editor is running, a
Tem
p
folder.
p
• The Project window is
i d b C t b tt
accompan
i
e
d

by
a
C
rea
t
e
b
u
tt
on.
This allows the creation of any
assets that can be made within
Unit
y
, for example, scripts, prefabs,
and materials.
Rise Group
52
The Game view
• The Game view is invoked by
pressing the Play button and
pressing

the

Play

button

and

acts as a realistic test of your
game.
Play, Stop, Advance Frame Button

6HWWLQJ IRU 6FUHHQ 5DWLR

6HWWLQJ
?
IRU
?
6FUHHQ
?
5DWLR
• If
y
ou invoke the Maximize
y
button, you can play the
game at nearly fullscreen.
Rise Group
53
Pla
y
mode - testin
g
onl
y
!
y
g y
• In play mode, the adjustments you make to any parts of your
game scene are merely temporary
game

scene

are

merely

temporary
.
• It is meant as a testin
g
mode onl
y,
and when
y
ou
p
ress Pla
y

g y,y p y
a
g
ain to stop the
g
ame, all chan
g
es made to active GameOb
j
ects
during play mode will be undone.
• This can often trip up new users, so don't forget about it!
Rise Group
54
Summar
y
y
• Here we have looked at the key concepts you will need to
understand and complete the exercises in this book
understand

and

complete

the

exercises

in

this

book
.
• You are recommended to continue to read more on the topics
discussed in this chapter in order to supplement your study of 3D
discussed

in

this

chapter
,
in

order

to

supplement

your

study

of

3D

development.
• We've taken a brief look at 3D concepts and the processes used
by Unity to create games, we'll begin by completing a simple
exercise before getting started on the larger game element of
hi b k
t
hi
s
b
oo
k
.
• In the followin
g
cha
p
ter
,
we'll be
g
in with a short exercise in which
g p,g
y
ou will protot
y
pe a simple
g
ame mechanic usin
g
Primitive
shapes generated by the engine itself, and some basic coding to
g
et
y
ou started in C Shar
p
(C#).
Rise Group
g y p
55
Practice
• Create a Cube, a Cylinder, and a Sphere and
h f b f i lf
t
h
en create pre
f
a
b
s
f
or
i
tse
lf
.
• Set the Ri
g
idbod
y
for each ob
j
ect and set
g y
j
the Material of Collider as ‘Bouncy’.
• Remove the cube
,
c
y
linder and the s
p
here
,y p
object which are in the Hierarchy Panel.

Create two new objects from each prefab
Create

two

new

objects

from

each

prefab
.
And give a new position for the second
generated object.
generated

object.
• Run the application and show the result.
Rise Group
56
Rise Group
57
Execution Result
Rise Group
58