B1 中級 4136 タグ追加 保存
The camera is one of the most
essential components in Unity.
The camera takes the contents of our scene
and displays it to our users.
Every scene must have at least
one camera to render out scene objects
otherwise we have nothing to show.
When a new scene is created
one game object is always created.
This is the main camera.
The game view camera is a
component attached to a game object.
This means we can manipulate, or move our camera
like any other game object,
including parenting, scripting,
or physical interaction.
To create a first or third person camera,
including side scrollers,
we can use the player object as the parent.
For first person cameras, make sure the camera
is at the character's eye height
looking forward from the character's point of view.
For a third person view, make sure the camera is
above and behind the character.
For a simple puzzle game or top-down shooter
the camera would be static, simply
looking at and rendering the game.
In this example we are going to centre the camera,
remove any unwanted rotation,
point it straight down and lift it above
the game board to simulate a top-down game.
In this case we are using the orthographic
mode on the camera, which we will cover
later in this lesson.
We can have any number of cameras in our scene.
Each rendering different parts of the environment.
In this example we have three cameras.
One rendering all of the dynamic
objects in the scene. Another rendering
the static background and a third
rendering a User Interface overlay.
All three cameras can be brought together to
make a single presentation to our user.
We will talk about how to properly use all
three cameras at once later on in this lesson.
When a camera is selected in the hierarchy
we see a preview of the camera in the scene.
When we have multiple cameras in the scene
this helps us to see what the camera is rendering.
This preview is also helpful when we are in
full screen mode to see what the camera is rendering,
even if it's the only camera in the scene.
Cameras will render everything that's in
front of them and within their view.
How much of the scene is within their view
is shown in the scene view as a white outline.
This shape is a view frustum.
A view frustum is a pyramid, or cone,
with the top cut off.
The cut off top of the pyramid is the
near clipping plane and the base
is the far clipping plane.
The near and far clipping planes control
the draw distance from the camera.
Objects must be between the near and far
clipping planes to be rendered. The sides
indicate how much the camera can see
side to side and top to bottom.
and any part of the scene that's within
the frustum will be rendered.
Cameras have two different ways of
looking at the scene. Perspective mode
and orthographic mode.
These dramatically effect the shape and
size of the frustum and the
look of the scene through the camera.
In perspective mode the camera will render
the scene like a real world camera with
a sense of diminishing perspective.
We can see this in the scene view as the
white representation of the cameras
frustum gets larger as it extends
away from the camera.
This is the most common camera mode to use
when creating a game.
In orthographic mode there is no
diminishing perspective. All objects are
rendered using a form of parallel
projection from the camera. We can see this
in the scene view as the frustum is straight
and the front and back are the same size.
This mode is usually seen in isometric
games like some real time strategy or
board games, or for 2D
games, simple puzzle games and when using
an additional camera for rendering UI elements
on top of the game view, like mini
maps or heads-up displays.
To control what is being rendered in our
scenes, adjust the near and far clipping
planes and the size or shape of the frustum.
Field Of View controls how wide the view
of the camera will be. This is very much
like using the zoom on a real world camera.
When the camera is in orthographic mode
size replaces the field of view property.
This controls the size of the
orthographic viewport.
This is similar to field of view but
the value of the size property changes
the size of both the front and back planes
at the same time as there is no perspective
with an orthographic camera.
Our scenes must have some sort of a background.
This controlled by the Clear Flags and
Background properties.
The colour values set in the background
property will be what's drawn behind any
of the objects in our scene, if no other
settings have been changed. This is the
default blue colour we see in a new empty scene.
Clear Flags determines what the background
will be for a camera. This setting is particularly
important when using multiple cameras.
Each camera stores colour and depth information
when it renders it's view. The portions of the
screen that are not drawn upon are considered empty.
The Clear Flags property will determine
what is shown in this empty space.
If we have a skybox set in our render
settings the background will be a skybox.
Skybox is the default clear flag for any camera.
A skybox is a material that contains
several images that surround the entire scene
providing a textured background for that scene.
For more information on skyboxes and
render settings see the appropriate lessons.
If we don't have a skybox set, or we choose
solid colour as our clear flag.
The colour value from the background property
will be used behind any of our objects
in the scene.
Depth Only is primarily used for
multiple cameras. We will cover depth only
in a moment.
Don't Clear will result in each frame
being drawn over the last, creating
a smear effect. This setting isn't typically
used in games.
When using multiple cameras the most practical
setting for clear flags is depth only.
With this setting each camera is given a
value and depth and the contents of each
camera's view are layered on top of each other
in depth order, starting with
lowest depth first.
Normally the main camera is assigned
the lowest depth value
and has it's clear flag set to either
skybox or solid colour.
All of the other cameras have their clear
flags set to depth only. This way there is
one ultimate background, and the images
of all the other cameras are
layered on top of the main camera.
The content of what the camera is rendering
is limited by the Culling Mask property.
The Culling Mask drop down will list
all the layers available in the scene.
The camera will render only those objects
on the layers selected in it's culling mask.
For more information on layers and how to
use then see the appropriate lesson.
In the case of the User Interface overlay
we have the interface element set to the
UI layer. Our UI camera has it's culling mask
set to render only the objects on the User Interface layer
We have our clear flag set to depth only
and the depth set to the highest value
of all the cameras in the scene.
This way the UI camera only draws
the UI element based on the culling mask
setting and the UI element draws on top
of all of the other layers, based on the depth.
It is also worth noting that the camera is set to
orthographic to remove any possible
perspective on the UI element.
Typical uses of multiple cameras
are to render UI elements like
mini maps or heads-up displays over the
world view, make rear-view mirrors and
missile cameras, or to force the drawing order
of objects in the scene, like making
sure that a gun in a first person shooter
doesn't get drawn inside the level geometry.
The normalised viewport rect, render path,
target texture and HDR properties
are more advanced and will be covered in an other lesson.


カメラ-Unity公式チュートリアル (Cameras - Unity Official Tutorials)

4136 タグ追加 保存
朱瑛 2014 年 5 月 2 日 に公開
  1. 1. クリック一つで単語を検索


  2. 2. リピート機能


  3. 3. ショートカット


  4. 4. 字幕の表示/非表示


  5. 5. 動画をブログ等でシェア


  6. 6. 全画面再生


  1. クイズ付き動画


  1. クリックしてメモを表示

  1. UrbanDictionary 俚語字典整合查詢。一般字典查詢不到你滿意的解譯,不妨使用「俚語字典」,或許會讓你有滿意的答案喔