Unity Basics

In this section, we’re going to work our way through the basic mechanics of the Unity engine. The workflow in Unity goes something like this: create an entity to serve a role in the game (blank GameObjects can be used for abstract logical tasks). Then, either write or find a class file, and add it to the entity as a script (using the ‘add component’ but- ton in the ‘inspector’ view. Then run, test, debug, repeat until it works and move on to the next element of the game.

Unity comes with a number of basic view tabs that can be laid out in various ways to the taste of the user. The big five are the ‘game’ tab, the ‘scene’ tab, the ‘inspector’ tab, the ‘project’ tab, and the ‘hierarchy tab. The game tab, when the ‘play’ button is depressed, displays a running instance of the game that the user can interact with and test. The ‘scene’ tab provides a static, editable version of the gameworld.

The ‘inspector’ tab allows the user to modify individual entities in the game world by selecting them in the ‘editor’ tab. The ‘project’ tab allows the user to browse through the project’s files and drag models, materials, and other resources into the ‘editor’ tab to place them in the gameworld. Finally, the‘hierarchy’ tab shows all objects in the world, allowing you to find distant objects in the scene, and parent entities to one another by clicking and dragging. See the diagram below for the locations of all these things.

5.1 Unity Entities

5.1.1 Meshes

Meshes are the way 3D geometry is represented in Unity. The user can either use Unity’s built-in ‘primitive’ objects (cubes, spheres, cylinders, etc), or import their own 3D models from a modelling package like Blender or Maya. Unity supports a variety of 3D formats, including Collada (.fbx), and .3ds.

The basic tools for manipulating meshes are the scaling, rotation, and translation buttons in the upper left corner of the interface. These buttons add control icons to the models in the editor view, which can then be used to manipulate them in space. To alter the texture or physics properties of an object, select them and use the ‘inspector’ view to ana- lyze the ‘material’ and ‘rigidbody’ elements.