Creating and instantiating a virtual Earth prefab
In this section, we will create prefab game objects for each of the planets. Since each of the planets has similar behaviors (for example, they rotate), we'll first create a generic Planet Prefab, and then make each specific planet a variant of that one. In Unity, prefab variants allow you to define a set of predefined variations of prefabs, such as our planet one (see https://docs.unity3d.com/Manual/PrefabVariants.html). We'll write a Planet
script that animates the planet's rotation and handles other behavior. Each planet will have its own "skin" defined by a material, along with a base texture map, which we downloaded earlier from the web.
In this section, we'll create a generic Planet Prefab object, create an Earth Prefab as a variant, add planet metadata by writing a Planet
component script, and implement a planet rotation animation.
Creating the generic Planet Prefab
The Planet Prefab contains...