Unity Camera Components

Source: Internet
Author: User

Today look at how the camera inside the Unity3d is called and manipulated.

Open Unity3d to create a new project. When we open the project, Unity3d will actively add a main Camera in the Hierartchy view. Click Main camera to show the component information of main camera in inspector.


in the camera component, you can adjust some of the properties of the camera.

Clera flags: Clears the tag. There are 4 options in the drop-down menu.




Skybox: Sky box, background display sky box. If the camera does not add the sky and the background color is displayed. Solid color: solid color, background display I did not background in the tone of the bukkake. Depth only: Depth does not show any backgrounds. The blank space is transparent. Don ' t clear: do not clear, draw each frame above the next frame, causing smear effect. Rarely used in general.

Background: Background color.

Culling mask: rejects the mask and selects whether the object is rendered by the camera by a label.

Projection: Camera type, divided into perspective camera and orthogonal camera.




Perspective: Perspective camera.

Orthographic: Orthogonal camera.

Difference






Perspective effect

Orthogonal effect

When we choose perspective is field of view: field of view, adjust the camera's field of view.

When we select the orthographic is size: Sets the viewport size of the orthogonal camera.

Clipping Planes:near is a close cut and far is a long distance crop.

Normalized view Port Rect: A four value indicating where the camera's view will be drawn on the screen, using the screen coordinate system (value 0-1). (Note: 0 of the screen coordinate system, 0 points in the lower left corner of the screen)

This is the parameter that is used for the screen split screen in unity.

Give an example of how to split the screen:

First create a camera.




The Normalizedview Port rect property of the main camera is x:0,y:0.5,w:1,h:0.5.

This means that the camera displays a coordinate of (0,0.5) width of 1 and a height of 0.5.

The normalized of the newly added camera ViewPort the x:0,y:0,w:1,h:0.5 in the Rect property.

This means that the camera displays a coordinate of (0,0.5) width of 1 and a height of 0.5.

The game view displays the following results




Depth: Depth, used to determine the drawing order of different cameras. A camera with a larger value will be drawn on top of a camera with a smaller value.

Rendering path: Render path with four options below use player Settings: using player settings. Vertex Lit: Vertex illumination. Forward: Fast Rendering. Deferred Lighting: Delayed illumination. Select the appropriate render path according to the project requirements.

Target Texture The destination texture, which places the camera's view onto a texture that can be applied to another object. This makes it easy to create large-screen stadiums, surveillance cameras, reflections and so on.

Flare layer: The glow layers, which let the lens Glow (lensflares) appear in the image. By default, the camera is already affixed with the Halo layer (Flarelayer).

GUI layer: User interface layers, so that the two-dimensional graphical user interface can be rendered. In the View panel click on the GUI layer (GUI layers) checkbox, you can enable and disable the drawing GUI on the camera.

Audio Listener: Voice listener, audio listener plays a device like a microphone. It receives any audio source (Audiosource) that is entered in the scene and plays the sound through the computer's speakers.

The basic properties of such a camera have been introduced. Let's look at how to add a sky box to the scene.

The first step: Select the camera and click Component->rendering->skybox in the menu bar.




Then in the Inspector view at the bottom of a column skybox.

Then add a sky ball to him. How to make the sky ball,

One: Create a new material ball




Select the new material ball, named Skybox1, and set the material to the Skybox type.



Results



Add the appropriate image to the appropriate place. Such a sky ball is finished.

An easy way to do this is to import Unity3d's own resources with a self-made sky ball.

(Note: Make a sky ball yourself is to note the properties of the picture Wrap mode property


should read Clamp format, or the seams will appear. )

When the sky ball is finished, add the camera


Let's take a look at how to achieve dynamic switching between the two cameras.

First we create two cameras in unity. The camera0,camera1 are respectively.

Create a JS script file. Write the code.

    1. var Camera0:camera; Define a camera object named CAMERA0
    2. var Camera1:camera; Define a camera object named Camera1
    3. function Update ()
    4. {
    5. if (Input.getkey ("1"))//if tapping on the keyboard "1"
    6. {
    7. Camera1.enabled = true; CAMERA1 activation
    8. camera0.enabled = false; Camera1 stop
    9. }
    10. if (Input.getkey ("0"))//if tapping on the keyboard "0"
    11. {
    12. camera1.enabled = false; Camera1 stop
    13. Camera0.enabled = true; CAMERA1 activation
    14. }
    15. }
Copy Code


Add the script to a game object to run the game. Tap the 1 and 0 keys on the keyboard. Detection code.

Unity Camera Components

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.