Sky box
A typical 3D game will have a hundred-year-old blue sky in Beijing, which is amazing. In fact, the effect of the sky is nothing mysterious. You only need to use the components of the sky box. You can imagine the sky as a huge box, this box contains the entire game view and all game elements. It is very convenient to create a sky box in unity, just set it like setting other components. Before creating a sky box, we need to collect some sky textures. However, Unity provides developers with a resource package for the sky box easily. First, right-click the project view, and select import package -- skyboxes to add the resource package of the sky box.
There are nine sky Resources in the resource package. Because the sky box is a cube, all of them need six textures. Select the first one, in the Inspector view on the right, the texture of the six faces in the sky box is displayed:
Skybox Components
Because the front of the camera is the content displayed by the game, a skybox component is bound to the camera to display the sky box textures. First, select the camera object in the hierarchy view, and then select component -- Rendering -- skybox in the navigation menu bar. You can add the box to the camera object. Then, set the custom skybox (custom sky box) Texture resource in the Box component, click the button on the right, select a texture in the pop-up window for selecting the sky box texture, and then run, the beautiful sky will appear in your sight.
After setting, adjust the camera's position and the sky effect, for example:
Note: If a game has a camera object, it is no problem to add a sky box, but there are multiple camera objects. After switching between cameras, the location of the sky box will be faulty. Because the texture resource is only relative to the current camera object. So how can we solve the problem of sky boxes in multiple cameras? See the following.
Add a sky box to the scene
You can directly set the box in the game scenario to avoid the problem of texture display after switching the box setting by multiple cameras. Select edit -- render setting from the navigation menu. Open the rendering settings page, set the sky material in the skybox material option on the page, and then apply it directly to the game scene. This can avoid the problem, because it will be the real box in the game industry. After running:
Add materials for the sky box
Developers can add the materials of the box to meet different requirements. First, select renderfx/skybox from the shader drop-down list, use the texture resource to assign values to the six-sided texture.