Unity Basic Terminology

There are a few foundational concepts that are worth understanding in Unity. These concepts are used in a variety of ways, as will be shown in later sections.

Assets: There is a directory tree of “assets” in Unity. This is basically a directory tree of files on disk holding the contents of a project. When you import a VRoid character, it expands the VRM file into a directory tree of assets, such as bitmap files for the texture of the skin and clothes, the mesh, blendshape definitions for controlling facial expressions, and more.

Scene: One type of asset is a scene, ending with a “.unity” file extension. A scene is stored in a single file, but has a complex hierarchal internal structure. In a game, each game level may have its own scene. In an animated movie, you may create a new scene instance per, um, scene in the movie. You generally have one scene loaded at a time to work on, then save it before moving to the next scene.

Hierarchy: Normally refers the hierarchy inside a scene even though the asset folder tree is also effectively a hierarchy too. The “root” (top) of a scene hierarchy is a scene object. Everything else that exists in the scene nests under this root object.

GameObject: A scene hierarchy is made up of a tree of GameObjects. GameObjects can have nested GameObjects (children), just like a directory on disk can contain nested directories. GameObjects must have components added to make them do something or become something (character, tree, lights, etc). An “empty” GameObject has no components but can still be used to group other objects together. That is a difference between GameObjects and assets. The asset hierarchy has files and directories which can contain other files and directories. The scene hierarchy is made up of objects. Any object can have children. Game objects can use assets. Saving a scene saves all the objects in the scene.

Component: GameObjects can have components added to give them behavior. For example, objects that can be seen in the scene will have a component to render the object. Other components can perform actions like adjust an expression on the face of a character. All components automatically get a Transform component which defines the position of the object in the scene (although many objects are not visible in the scene so don’t really need a location).

Properties: Most components have properties that you can change the value of. For example, the Transform component has properties for X/Y/Z position, X/Y/Z scale, and X/Y/Z rotation. The type of component determines what properties are available. Properties generally have simple types, such numbers, strings, colors, and so on. Properties can also hold arrays and references to other objects and assets.

Transform Component: The Transform component gives a GameObject an X/Y/Z coordinate (position), X/Y/Z rotation, and X/Y/Z scale. Any object that appears in a scene (a character, some furniture, a light source, the camera, etc) has a Transform component to keep track of the location of that object in the scene.

The position of a component is relative to its parent object. So if the parent object has X=1 and the child object has X=2, the child object will have position X=3 in the scene (assuming there are no rotation or scaling in effect). This is very useful to place objects relative to each other where if you scale/move the parent object everything under it moves together, or if you move one of the child objects it will move relative to the other objects under the same parent. For example, if you want two characters walking alongside each other, you might put them under the same parent with a different X offset (sideways offset) so they both move together in sync

Script: GameObjects can have scripts (programming logic, typically C# code in a file with a “.cs” file extension) added via the Script component. Multiple script components can be added to the same object if desired. These are used to implement more advanced logic than is possible using the built-in set of components. For example in a game, when you finish a level, a script could be used to check if you got a high enough score to proceed to the next level of the game. For an animated movie, a script might be created so a character moves to a particular position within the scene. (There are multiple ways to achieve this.)

Function: Scripts contain classes containing functions that can be called. A function is an entry point into a script. One script may make multiple functions available. For a component that moves a character, it might have a MoveTo(X, Y, speed) function which will make the character move to the requested scene location at the requested speed.

Events: Another thing scripts can do is define functions with special names that will get called when certain events occur, such as when the current GameObject collides with (bumps into) another GameObject. The script might make a change such as change the direction of movement (for when an object bounced off another object).

Prefab: A prefab is a saved GameObject with all of its components, property values, and child GameObjects as a reusable environmental asset (file extension is “.prefab”). For example, you can assemble a location for your movie in a scene (ground, some buildings, trees, maybe lighting, etc), then drag and drop that object tree from the scene hierarchy to the asset folder tree. The copy made in the asset tree is now a “prefab”. If you drag the prefab from the asset tree into a new scene, a new copy will be added to the scene. You can add it once (your complete city layout) or multiple times (you create a cluster of trees and add many copies to your scene). Using a prefab is more efficient than copying the original objects from one scene to another the prefab is shared. If you update the prefab, all scenes using it will be updated too. Prefabs can be nested (a prefab for a city could contain the prefab for the cluster of trees). You can also make adjustments to a prefab in a scene (e.g. add additional objects as children). But there are limits to the adjustments you can make  without changing the prefab itself.

Some people seem to create a Prefabs directory, but to me it seems to make more sense to name the directory based on what it is, like “sets” (movie sets – prefabs for scene locations) and “props” (things like furniture).

Prefab Variant: You can inherit from a prefab then override parts of it.

With some of the basic terminology out of the way, we can start digging into the more advanced concepts in future posts.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s