Creating a Skybox 

When we create game worlds, we typically create the ground, buildings, characters, trees, and other game objects. What about the sky? By default, there will be a textured blue sky in your Unity game projects. That sky is sufficient for testing but does not add to an immersive gaming experience. We want a bit more realism, such as clouds, and that can be accomplished by creating a Skybox. 

A Skybox is a six-sided cube visible to the player beyond all other objects. So, when a player looks beyond your objects, what they see is your Skybox. As we said, Skyboxes are six-sided cubes, which means you will need six separate images that can essentially be clamped to each other to form the cube. 

The following screenshot shows the Default Skybox that Unity projects start with as well as the completed Custom Skybox you will create in this section:

To follow along, you will need the six images located in the Chapter5-Skybox.zip file on the publisher's companion site.

Perform the following steps to create a Skybox:

  1. In the Project panel, create a Skybox subfolder in the Assets folder. We will use this folder to store our textures and materials for the Skybox.

 

  1. Drag the provided six Skybox images, or your own, into the new Skybox folder. 
  2. Ensure the Skybox folder is selected in the Project panel. 
  3. From the top menu, select Assets | Create | Material. In the Project panel, name the material Skybox.
  4. With the Skybox material selected, turn your attention to the Inspector panel. 
  5. Select the Shader drop-down menu and select SkyBox | 6 Sided.
  6. Use the Select button for each of the six images and navigate to the images you added in step 2. Be sure to match the appropriate texture to the appropriate cube face. For example, the SkyBox_Front texture matches the Front[+Z] cube face on the Skybox Material.
  7. In order to assign our new Skybox to our scene, select Window | Lighting | Settings from the top menu. This will bring up the Lighting settings dialog window.
  8. In the Lighting settings dialog window, click on the small circle to the right of the Skybox Material input field. Then, close the selection window and the Lighting window. Refer to the following screenshot:

You will now be able to see your Skybox in the Scene view. When you click on the Camera in the Hierarchy panel, you will also see the Skybox as it will appear from the camera's perspective.

Be sure to save your scene and your project.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset