Making the Splash scene

The Splash scene we are building is very basic for now, with just some status messages. You can, of course, style it and add any images you like later on. Open up the editor and complete the following:

  1. Create a new scene called Splash and save the scene to the Assets/HoloCore/Scenes folder.
  2. From the menu, select GameObject | UI | Panel. This will add a new Canvas with a child Panel and EventSystem. Set the background color of Panel to a dark gray.
  3. Select the Panel and, from the menu, select GameObject | UI | Text. Change the name of the object to Status and set its properties in the Inspector window, as shown:
Setting the Status text properties
  1. This is the where we will display those status messages back to the user, which means that we need a script that can update the status messages as well as know when the service has been loaded and the application can start.
  1. Create a new C# script called SceneLoader in the Assets/HoloCore/Scripts folder and replace the pre-generated code with the following:
using UnityEngine;
using UnityEngine.UI;

namespace Packt.HoloCore
{
public class SceneLoader : MonoBehaviour
{
public string sceneName;
public Text statusText;

void Update()
{
if (SceneController.Instance.isLoaded)
{
SceneController.Instance.LoadScene(sceneName);
}
else
{
statusText.text = SceneController.Instance.status;
}
}
}
}
  1. This simple class is what we will use to track the status of our SceneController. All the action takes place in the Update method. We first check whether the SceneController has loaded by testing isLoaded. If the scene has not loaded, we display the status text in the statusText.text object. Remember that the Update method is run every rendering frame, so we are testing this condition several times a second. Save the script, and next, we need to add it as a component to our scene.
  2. Return to the Unity editor and wait for the new class to compile.
  1. Create a new object called ScreenLoader and add the new ScreenLoader script to it. Then, set the properties of SceneLoader to what is shown here:
Setting the SceneLoader component properties
  1. Set the Status Text property to the Status object. You can use the bull's-eye icon to select the object from the scene or just drag the object from the Hierarchy window and drop it into the slot.
  2. Save the scene.
  3. Open Build Settings, add the Splash scene to the build, and ensure that it is the first scene, as follows:
Adding the Splash scene to the build
  1. Go ahead, connect, build, and run. You will now be taken to location as identified by the Location service, that is, if you allow the service to connect.
..................Content has been hidden....................

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