Chapter 3. Singletons, Statics, GameObjects, and the World
Every level or game world in Unity is represented by a scene, and a scene is a collection of game objects situated inside a Cartesian 3D coordinate system with x, y and z axes. Units in a scene are measured in Unity units, and these correspond (for practical purposes) to meters. In order to script masterfully with Unity, it's critical to understand the anatomy of both scenes and objects and how interobject communication happens; that is, it's important to know how separate and independent objects in a scene can communicate with each other to make things happen as you expect. Consequently, this chapter focuses on the native Unity methods available to optimally search, reference, and access objects in a scene. It also focuses on additional concepts such as statics and singletons for the creation of objects that travel between scenes, retaining their data as they move. Of course, this chapter will not only consider...