Probably the most important window is Scene – here we can see our game level and game objects in 3D environment. It shows grid on XZ plane at Y = 0 (or ground level).
1 Displaying Scene
At the top of the window we can see display options for scene. First dropdown list lets us choose how game objects are presented on the scene. Next is responsible for colouring. After that we have four switches:
- Light on/off
- Audio on/off
- Effects (we can tick which should be visible)
Last element, named Gizmos, allows us to set visibility of additional parameters like grid, audio sources etc.
2 Controlling Scene
Near the top right edge we can see how scene camera is oriented and change its orientation, e.g. to look from bottom/top (on Y axis). We also can change camera orientation by holding RMB and moving mouse on the scene window. While doing that we can also move in Scene using WASD keys. We can also rotate by holding LMB and Alt key. When we do that you can see that first of the button at the top left corner of Unity windows changes to eye. Let’s learn something about them.
First, which was changed during holding RMB and normally has hand symbol enables us to move in scene through ‘dragging’ it. So when we have it selected to move scene to the right (in current orientation) we need to hold LMB and move cursor to left.
Next allows us to move selected object by dragging one of the coloured arrows lying on axes. Similar to this is button which enables to rotate object and last one which allows us to scale object.
Last thing you need to know is zooming – it’s done by scroll-wheel of the mouse.
3 Game Objects
When working in Unity we’ll be using a lot of game objects to create virtual worlds – nearly everything will be created from them.
3.1 Creating game objects
We can create game object in 3 different ways:
- Using option GameObject->Create Empty to create empty object (equivalent to Ctrl+Shift+N)
- Using option GameObject->Create Other…->[any option] to create predefined objects like primitives or camera
- Drag and drop asset or prefab (described later) from Project window
First two option will create object located at (0,0,0) while drag & drop will place it where dropped. Created object will also be automatically selected in Hierarchy window (it makes easier changing the name of just created objectJ) and its data will populate Inspector.
3.2 Basic properties
All game objects have common properties located at the top of the inspector.
The colourful cube is dropdown list which enables us to label or icon visible in Scene window – this is particularly helpful when dealing with ‘invisible’ game objects. Checkbox next to it determines if object is visible in Scene. We can also rename it here (or in Hierarchy) and set if object is static (like wall or rock). It’s used for optimising application, because static objects are taken into account in culling phase of rendering scene – so it will disable mesh objects behind them. We can also set tag for object and its layer. Underneath we have Transform component. It sets rotation, position and scale of the object.
For the first exercise prepare Unity environment:
- Make custom layout and save it
- Set project for source control
- Create scene representing game of tic-tac-toe using spheres and squares