GEOG 497
3D Modeling and Virtual Reality

Getting More Familiar with the Editor

Print

Getting More Familiar with the Editor

It is time to get more familiar with the interface and components of the Unity Project Editor and get some practical experience. The Unity web page provides video tutorials on the basics and some advanced aspects of the Project Editor that we are going to rely on here. So please grab a cup of coffee, tea, or whatever you prefer, and watch the videos listed below. Please pause often to try out and practice the things explained there on the project you have. In particular, make sure to practice changing the view by panning and zooming, as well as quickly changing the perspective with the View Gizmo and manipulating objects in the Scene view. If something goes completely wrong, you can always delete all the folders and re-import the unity package and then start over.

Video: Interface Overview (2:17 min)

This short video describes the main windows of the editor interface you already heard about but mentions a few more details. Please note that the layout of the windows in the video has been changed so that the Scene Window and Game Windows are visible at the same time.
Click here for the Interface Overview video transcript.

Navigating the Unity editor interface is easy. The core of the interface consists of five main panels. The Scene View, the Hierarchy, the Game View, the Project panel and the Inspector panel. The Scene View is where you'll visually construct your game, manipulating objects in 2D and 3D. The Game View is where you will preview your game, and this becomes active when you hit the play button, allowing you to playtest at any time inside the editor. The Hierarchy lists all objects in the scene in alphabetical order and in hierarchical order in order to show parenting, a way of grouping objects. The Project panel shows all assets that you are currently working with, in one place, giving you quick access to everything you are building your game with from scripts to textures, 3D models, video, and audio. The Inspector is a context-sensitive panel that shows the properties of whatever object, asset or setting panel you've selected. Click on something new and the Inspector immediately switches to show properties of that thing. The play controls allow you to playtest the game, pause, and progress frame by frame for more detailed testing. The tools in the top left allow you to navigate the Scene View and also manipulate objects visually. There are also toggles to allow for switching between local and world space and center or pivot point based rotation. The Layers dropdown allows you to quickly show and hide layers of content in your game. The Layout dropdown allows you to switch between differing layouts of the Unity interface. In the top right of the interface are the layers and layout dropdowns. This concludes the interface overview. Continue to watch tutorials to learn more about each individual panel. Subtitles by the Amara.org community

Video: The Scene View (4:20 min)

Here you learn more details about interacting with the Scene view and the different tools for manipulating objects. Please pause and try out the different tools yourself.
Click here for the Scene View video transcript.

The Scene view is where you will visually construct your game. And this can be navigated by making use of the buttons above the view. These buttons correspond to the Q, W, E and R buttons on the keyboard. The first button, the Hand Tool, is purely for navigating. With this tool selected drag with the left mouse button to pan, and with the right mouse button to look around First Person style. Hold the Alt key with this tool and left mouse button drag will let you orbit around the point you were looking at. Whilst Alt and right mouse button dragging will zoom the view. With any object selected in the hierarchy, you can focus on the object either by double-clicking the object's name or by pressing F with the mouse cursor over the Scene view. The remaining three buttons allow you to adjust position, rotation, and scale of objects. By dragging the corresponding axis handles you can move objects in X, Y or Z. Likewise, this also applies to moving in 3D by dragging from the center, although this is not necessarily recommended for moving in 3D space. Likewise for rotating you can rotate in all three axes, or you can just drag from within those, but again a lack of control will occur when trying to drag in all three axes at once. And again with scaling you can scale objects in all three individual axes or drag from the center point in order to scale uniformly. In this instance, it is recommended to drag from the center in order to keep scale properties in proportion. In the main bar of the Scene view, you will see two drop-down menus that handle how the Scene view is rendered. You can switch to wireframe or look at alpha of how your objects are displayed for example. These are followed by three toggles. The first toggle toggles lighting in the scene The second - whether a skybox is rendered or not. And the third allows you to preview audio from the game from wherever the editor camera is currently located. The editor camera simply refers to the camera that you are looking at the Scene view from. It is not a camera object in your scene. So for example, if I were to move my camera very far away from the sound source and preview the audio again. You can hear that it's quieter than it was before. To the right of the panel are the Gizmo menu and search box. The Gizmo menu lets you adjust gizmos, the 2D icon shown in the Scene view to help you identify components in the scene. Such as lights, audio sources or cameras. These can be adjusted by size and also be toggled between 2D and 3D. The search field lets you search for a particular object by searching for its name. And this highlights the object by fading out other objects in your scene. Again, if you are not focused on the actual object that you've found by searching then you can simply use the Focus feature to find it. This search also singles out the object in the Hierarchy so by then selecting the object you were looking for and pressing F to focus, or double-clicking - you will then be taken to that object. The final part of the Scene view you should understand is the View Gizmo itself. This allows you to switch from Perspective 3D view to Orthographic cameras from sides, top and bottom. When dragging to orbit your view in Orthographic view you will be switching to Isometric view. You will be notified of this by the term ISO written underneath the View Gizmo but do not confuse this with actual 3D Perspective view and be aware that you can switch back to Perspective view simply by clicking on the white cube in the center of the View Gizmo.

Video: The Game View (3:11 min)

Here you learn more about the different options for changing how a Unity project will be rendered in the Game Window. The video also provides more details on what changes done while in Play Mode will only be temporary and which will be permanent.
Click here for the Game View video transcript.

The Game View in Unity is invoked when the Play button is pressed. In this, you can playtest your game and get an idea of what the gameplay will be like when it's built. This can be paused and stepped forward at any time in order to give you more accurate testing. You can also tweak things whilst you are in play mode in order to see what the gameplay is like with different settings. The game view also allows you to set resolution specific to the target platform that you're using. For example, my game view is set to Standalone with a resolution of 1280 by 720. If I choose to then maximize on play the game view will restrict to exactly that resolution so that I can see what it will look like. To adjust this I go to Edit - Project Settings - Player and this shows me the default screen width and height under resolution. If I edit this I will see the change made immediately in the game view. And if I choose to switch to a different target platform I will get the resolution for that setting. For example, if I switch to Web Player and return Web Player is then featured as the target platform I'm building for and the preview mode for the game view. In addition, to Maximise On Play, the game view also has a Stats button to allow you to see performance statistics based on your game and also the ability to show Gizmos in the same way that the Scene view shows them already. As you can adjust things whilst in play mode you should also be aware that any changes that you make will be undone when returning to your project. This is specific to changes that are based on game objects in your scene and not game objects that reference assets in the project. For example, if I was to change something relating to a material that change is made to the original asset. Whereas if I was to change something on a specific component that change will be undone when play is pressed again. It's also worth being aware that when you press play, your game is running and you can hint this by going to Unity - Preferences on Mac or Edit - Preferences on PC. You can choose under Colours a play mode tint, I've chosen a shade of blue, but I can make this any colour that I need to. That way, when you press play the rest of the interface will change to this colour. This is to remind you that you are in play mode and will lose changes if you continue to work in that mode.

Video: The Hierarchy and Parent-Child Relationships (3:48 min)

This video elaborates on the GameObjects being arranged in a hierarchy and how this can be used and describes additional elements of the Hierarchy Window.
Click here for The Hierarchy and Parent-Child Relationships video transcript.

The Hierarchy in Unity is a complete list of any object in your open scene. Objects are listed from A to Z order, but it is also possible to create hierarchies of objects which are in turn listed in A to Z order. Hierarchies of objects mean that they are grouped, with the topmost object being called the Parent Object and the rest being referred to as Children or Child objects. These objects then have their transform values based upon that of their parent object. For example, the position of an object when loose in the hierarchy is based on its distance from the world origin or zero point. But when this object is made a child of another object it's position is relative to that of its parent. In this example, the character object is at the origin of the 3D scene, the position (0, 0, 0). And there is a cube object at position (5, 1, 5). But when the character object is made a child of the cube - its origin, or zero point, is then the position of the parent object, the cube. Now the character's position is said to be (-5, -1, -5). This being the distance from the cube object, it's parent and therefore it's origin position. We can also see that with Pivot Point Rotation enabled the rotation is now based on the parent object rather than rotating around its own axis. The same then applies to movement and scaling. And this will apply until that object is no longer a child. Other features of the hierarchy are the Create button and Search field. The create button on the hierarchy acts as a mirror of the Game Object - Create Other top menu and this will allow you to create various different things that you will need to construct your games in Unity. Whilst the search field works in a similar way to the search field in the Scene view, allowing you to narrow down objects using their name. The scene view then reacts by greying out other objects allowing you to see the object you've searched for more easily. You can also make use of the modifier T: in order to search for types of object. Type here being considered as one of the objects components. For example, if I search for T:Light there is only one light in my current scene, one on the end of the players gun. And if I search for T: Audio Source I'll be narrowed down to 3 objects, the only ones in the scene that happen to have audio source components attached to them. When searching in this way, the bottom of the hierarchy shows the path to the object that you've found. Damage audio source being the one I have selected, Player being its parent and Cube being the parent of that object. This means that when canceling the search you can easily see where your object is. It will also remain selected and the parent objects of that object will be expanded to show where it's located.

Video: The Project Panel and Importing (2:34 min)

This video explains the relationship between the Project Window and the files stored in the Project folder on disk. Importing from the Asset Store mentioned at the end is something we are going to do in the next lesson.
Click here for the Project Panel and Importing video transcript.

The Project Panel is where you store all of the assets that make up your game. Anything you create with the panel, and any asset you import, will be kept here. You can create Unity-specific assets by clicking the create button at the top. Or import assets created in an external application. You can import by right-clicking, by using the top menu or simply by adding files to the assets folder in your operating system or by saving from another application. The project panel is a mirror of your assets folder. And when viewing the assets folder in your operating system you'll notice that meta files are created for every asset that's placed into the project. Note that once the asset is in you should always use the project panel to move it around or edit it rather than using your operating system as this can break lines in the library of your project. The project panel has two styles of view, one and two-column. These can be switched by clicking the context menu button in the top right. One column view lets you see assets in a simple hierarchy as shown here. Two-column view gives you more flexibility and more options to work with assets. You can select, move and duplicate assets in the project. Create and organize into folders. As well as label assets and search for them. Assets can also be previewed in a thumbnail form by dragging the slider at the bottom, with hierarchies then being shown with a right-arrow that can be used to expand or collapse them. Assets can also be searched for and sorted by their name, their type, a label or by a favourite grouping. To create favourites you could perform a search and then click the star button in the top right and give your new group a name. You can even search the assets store from the project browser. By typing in the standard search field and switching from assets to asset store.

Video: The Inspector (4:19 min)

This video explains the main elements of the Inspector Window in more detail and describes the purpose of tags and layers. Disabling components or entire GameObjects can be very helpful while building and testing a Unity project.
Click here for The Inspector video transcript.

The Inspector panel in Unity is a panel for adjusting settings for any object, asset, and editor preference. For objects, the inspector begins with a title, a checkbox for you to check if the state of the object will remain static in the game. This means it's a valid candidate for light-mapping and navigation mesh baking. And then the tag and layer drop-downs. Tags allow you to assign a tag to one or many objects in order to address them via code. Whilst layers allow you to group objects and apply certain rules to these layers such as lighting or collision rules. After these elements, the inspector then lists the components attached to an object. Beginning with the transform, the default position, rotation and scale of your object. On any component the inspector allows you to adjust fields in various ways. You can drag over the values, you can click and retype, or you can choose to reset the values using the cog icon to the right of the component. In addition to the cog, there is also a link to the reference material on the component and you can get to this by clicking the blue book icon, and this will open the documentation page on this component. A context-sensitive panel, the inspector changes to whatever you have selected, meaning that you can adjust any object and immediately dive into settings and back. Because Unity makes use of dragging and dropping to assign values sometimes you may click on items that take you to their settings, rather than the one you wish to apply them to. And for this reason, you can lock the inspector in order to work with a particular item and then unlock once you are done assigning settings. For example, on this game object, I have a script component to which I must assign an array of textures. But when I select my first texture I want the inspector to remain on my game object, rather than showing the texture's settings. I could simply hold down the mouse or I can simply select the object and click on the lock at the top of the inspector. This way when I select one or many textures I can then drag and drop without the inspector changing focus. Once I am done with this, I simply click the lock again and I can then select anything that I need to. The inspector also offers a way of finding assets used on objects. For example materials. When clicking on an asset used within a renderer you can see that asset highlighted inside the project panel. It does this by highlighting with a yellow outline. This helps you easily find the assets that your game objects depend upon. In this example, we can see an object that has a material assigned to its renderer. This particular material is then previewed at the bottom of the inspector and I can adjust that material directly from here. However, the other two objects that I don't have selected also use this material, so I must bear in mind that the actual material I am adjusting is the original material asset inside the project and not a particular instance of an object in the same way that I can adjust the scale of this object without adjusting any other objects that also have a scale value. Components within the inspector can also be disabled by clicking the checkbox to the left of their name. And the entire object can be disabled by clicking the checkbox next to its name at the top of the inspector. When objects are disabled in this way you'll notice that their name is greyed out inside the hierarchy panel. And that's the basics of the inspector in Unity.

Video: Build and Player Settings (1:50 min)

Here you get a little bit of additional information on the build dialog and player settings.
Click here for the Build and Player Settings video transcript.

The Build Settings can be accessed from the File menu by going to File - Build Settings. A build, in development, is a term used to describe an exported executable form of your project. And given Unity's multiplatform nature this varies for each platform. For web players, Unity will export an HTML file with example embedding code and a .Unity 3D file which contains your game and will be run by the Unity web player plug-in in your browser. For standalone Unity will export an executable version of your game for PC, Mac, and Linux. For iOS Unity exports an Xcode project that can be opened in Apple's Xcode SDK and run on the device for testing and submission to the app store. For Android Unity exports an APK file that can be opened in the Android SDK. Flash exports an SWF file associated assets, and yet again an HTML file with example embedding code. Google Native Client exports a Google Chrome browser compatible web player game. And for consoles Unity builds directly to your hardware development kit. The build settings work with Unity's player settings to define settings for the build that you create. Split into cross-platform and per-platform you can set some basic values at the top and then choose settings below that are specific for the platform you are developing for. One thing to note as a beginner is that the resolution in the Resolution and Presentation area is the setting you can select for the game view. For details of other per-platform settings refer to the manual link below.

Video: Game Objects and Components (2:12 min)

This video adds some information to what you already know about GameObjects and how they can be adapted in the Inspector. Adding a script component to an object is something we will do later in this lesson.
Click here for the Game Objects and Components video transcript.

Game Objects are the items that make up your Unity scenes Everything within a scene is considered a game object and these objects are made up of a number of components. Each has a necessary transform component that contains the position, rotation, and scale of the game object. Components can be added using the Add Component button at the bottom of the inspector. Or by using the Component top menu. Scripts are also considered as components and can be added using the aforementioned menus. They can also be created and added using the Add Component button. components can be removed, or copy-pasted using the cog icon to the right of their representation in the inspector. You can then select another object and paste them by clicking on the cog icon. You can also add a script to an object by dragging it to the hierarchy or to the object in the scene view. And you can even drag and drop to empty space in the inspector in order to add a script as a component. Game objects are seen in the hierarchy view as a list, with a hierarchy of parent-child relationships demonstrated by arrows to the left of their name. The Hierarchy is a list of all the game objects in the scene and as such everything that you see in the scene view is also listed in the hierarchy. And when selecting a game object in either view it's selected in both.

Advanced Unity Concepts

That was quite a bit of new material but now you a very good understanding of the unity editor. We are almost done with our video tutorials before we engage in some fun practical work in the next section where we will build a very simple game! Please take a few minutes to learn about some of the more advanced features of unity using the following three videos.

Video: Prefabs (1:32 min)

Prefabs are templates for GameObjects that you can quickly generate instances in your Scene from (e.g. placing a tree prefab in your Scene multiple times to model the trees in the actual environment). This can happen either when building the Scene or dynamically during the execution of the project.
Click here for the Prefabs video transcript.

Prefabs in Unity are preconfigured game objects that you create in the scene and store in the project. They can then be instantiated or cloned, meaning to create an instance of them during the game. They have all manner of uses and are a key part of development in Unity. They are used for everything from rockets to enemies, to procedural levels. To make a prefab simply create your game object in it's desired configuration in your scene, from whatever components you need, and then drag it to the project panel to save it as a prefab. It can then be deleted from the scene. To edit a prefab you can either select it in the project and adjust properties in the inspector. Or drag an instance of it back into the scene, edit it in the inspector, and then press the apply button at the top. This saves changes back into the prefab and you can then remove the instance from the scene yet again. Also, if you have many instances of a prefab, and you make edits to one of them, and decide you would like others to be the same you can hit apply. The other instances will inherit this update from the prefab's settings. Likewise, if you make a change to one of your instances and you decide you don't like it anymore you can revert to the settings of the prefab by clicking the revert button at the top.

Video: Tags (1:35 min)

In this video, you learn how to better organize complex Unity projects with the help of tags and how tags can be used in scripts.
Click here for the Tags video transcript.

Tags are a way of identifying game objects in Unity. As a name of a single object could identify it, it can be useful to set tags also. For example, you may have an object called Ork or Tank but these could all be tagged Enemy, and in your code, you could check for any objects that have the tag Enemy. Likewise, a script on an enemy could check for a player character by looking for a player tag. To assign a tag to an object, select it and use the drop-down menu at the top of the inspector. If the tag you want isn't already present then add a new tag. You can add a tag by clicking the option at the bottom of the menu and then entering it in the list of tags at the top of the tag manager. Once you've done this, return to the object you wish to place the tag on and select it from the drop-down. There are a number of functions in code, which will allow you to find objects with tags, the simplest one of these is GameObject.FindWithTag, which allows you to specify a string with the name of the tag inside it. This script is attached to my enemy object and I can use that to find an object with the tag Player. So I'll set my robot to be tagged Player and when the game starts my enemy is seeking out that object and looking at it. Likewise, you could find multiple objects with the same tag by using FindGameObjectWithTag. See the scripting reference for more examples of this.

Video: Layers (2:38 min)

In this video, you learn about structuring the objects in a scene into layers.
Click here for the Layers video transcript.

Layers are used to indicate some functionality across many different game objects in Unity. For instance, layers can be used to indicate which object should be drawn in the scene view, should ignore raycasts, or are invisible to the camera. Here we have a scene with 2 orbs in it. We can see that both orbs are on the layer Default. If we wanted to change the layer of 1 of the orbs we could click the Layer drop-down in the inspector and select a new layer. We can see that this orb is now on the Ignore Raycast layer and will not be hit by any raycasts that pass through it. We also have the ability to define our own layers. We can do so using the Tag And Layer Manager window. To access the tag and layer manager window either select Add Layer from the Layers drop-down or click Edit - Project Settings - Tags And Layers. Here we can see all of the built-in layers as well as add our own. Let's create an Ignored By Camera layer. We can place our other sphere on this newly created layer by selecting it and choosing the New Ignored By Camera layer from the Layers drop-down. This sphere is now on the Ignored By Camera layer. The layer has no inherent functionality however so let's modify our camera to ignore it. In the Culling Mask property of a camera we can select which layers are seen by the camera and which are not. By clicking the drop-down and unselecting the Ignored By Camera layer all objects on that layer will no longer be visible to that camera. Let's run our scene. We can see that only a single orb appears. The other orb, the one on the Ignored By Camera Layer is not rendered to the screen. We can also use layers to determine what appears in the scene view. By clicking on the Scene Layers drop-down at the top right of the Unity editor we can select and deselect layers. Doing so will cause all objects on those layers to disappear.