The Unity interface

Let's try to better understand what appears on the screen when you first start Unity.
Keep in mind that if you are new to the Unity interface, this will be a very important lesson that could determine your future as a Unity developer.
You will need to read this article carefully and learn the terminologies used here.
Each element described underpins the operation and understanding of Unity 3D.
We will learn the meaning of basic terminologies such as:




  • Hierarchy
  • Scene
  • Inspector
  • GameObject
  • Component
  • Transform

Running Unity for the first time you will find yourself in front of a tool divided into many windows full of buttons that invoke your click but which could be confusing at first.
But don't give up, you're in front of the most complete game creation tool ever conceived and you'll soon have full control over it!

The power of creation at your fingertips.

Let's examine the top of the screen.
There are four main areas, all of which are very important:
Hierarchy, Scene, Ranges e Inspector.

The Unity interface

Hierarchy
This is the hierarchy of objects in the current scene.
All the objects you will be working on will appear within this window. The objects in the scene are called gameObjects (game items) and they will all and always be listed in this window.

Scene
It is the working window where the current scene appears, it is in this window that you will work and build the game scene, moving, scaling and positioning objects as you like.




Ranges
It is the window where you will see the game as it really appears when it is run. It is an output-only screen (therefore you cannot interact directly with it), but inside it you will be able to see the result of the work you have done up to that moment.

Inspector
It is the inspector, i.e. the inspection window of the selected object. On this window you will be able to see all the information about the gamaObject selected at that moment, the scripts connected to it and all the characteristics it possesses. If it's completely empty at the moment, it's simply because you haven't selected any gameObjects .

In the beginning there will already be two gameObjects fundamental in the scene, a camera and a light.
As you can easily guess, the camera represents the point of view, it is the eye that frames the game. What the camera sees is what is displayed in the window Ranges.

What is meant by the word "Scene"?

A scene(s) is a game level. The game world can consist of infinite scenes that will be loaded as needed. Or, in some cases it is enough to have two or three scenes for an entire game, this depends on the complexity of the game in question.
NOTE : It is important to understand right away that when you pass from one scene to another, all the gameObjects in Hierarchy will be destroyed and i will be uploaded gameObjects of the new scene.
Therefore i gameObjects they are not automatically permanent for the entire game run unless you specify not to destroy a particular object when loading a new scene.




The most important element in game development:
i gameObjects.

All elements in a scene are gameObjects.
The camera is a gameObject, light is a gameObject, a character is a gameObject ecc… I gameObjects differ from each other according to the components that are assigned to them.
When selecting a gameObject, we could all see components present on that unpalatable gameObject in the window inspector .
By nature i gameObjects they are "empty", i.e. they are only "points in the 3D space of the scene" which do not perform any particular operation. What makes i gameObject functional are i components compose them (also called "attached to it").

The componets (components) on a gameObject

I components (components) are another fundamental building block on which all development of a video game in Unity is based. They are the elements that "fill" a gameObject and assign its characteristics.

For example, the camera does its job as a camera because it is a gameObject to which the "Room" component which makes it precisely, a camera. Without the Camera component, that gameObject it would not have the same functions and the same role in the game. A camera is such precisely because it is a normal gameObject with the Camera component.
To give another example, to have a 3D sphere inside the scene we would have to create a gameObject with the components of the “sphere model” on it.


DIVISION ON THE COMPONENT CODE.
In this guide, every time you read “DIVAGATION ON…”, it means that I am not expressly dealing with the subject of the session but I am "exploring" a topic inherent to it which has either already been treated or will be treated later.
In this session we are examining the Unity interface and therefore we will see later how to interact with components from code.



At the risk of going "off topic" with the lesson, I still want to familiarize you with one of the fundamental instructions that we will encounter in the code.

GetComponent();

With this simple line in the code we're going to "get" any component, so that we can manage it.
For example, with this line:

GetComponent();

We will have "read" the camera component so that we can manage it as we want directly from code, changing the zoom of the camera and many other features directly at run-time, ie while the game is running.


Any script is also a component. For example a script that makes a character move is a components, a certain VFX assigned to the gameObject of the camera is a components, etc..

All gameObjects consist of multiple components.

For example, a character moving across the screen will be a gameObject with the "character model" component that makes it appear on the screen and the "movement" script to make it move via player input.

The Transform component

This "component" can be defined as "special" because it is present on all gameObjects, always sits on top of all components and is the only one you can't delete from a gameObject.
As the name suggests, it represents all the “3D transformations” of the object intended as peculiarities of the gameObject in space, i.e. its scale, its rotation and its position in space. It can be defined as the component that identifies this gameObject on your scene.

Another important part of the Unity interface - the Project panel
The Unity interface

At the bottom of the Unity screen we find a window that can switch between Project e Sideboard through two tabs. We will see later what the Console is and its usefulness. For now let's focus now on the Project panel.

Inside the window Project we will find the project files or more commonly called “Assets”.

An asset is a "good", understood as a "useful element" for the developer.
Textures, sounds, models, scripts, materials and anything else you will use in a project will be called Asset.

Just like files in a Windows window within this window we could see any type of file that is part of the project that you can sort into folders and subfolders.
It is important that you keep your files well sorted by categories by creating folders that contain a certain type of file, so as to orientate yourself easily when you want to find a specific file.
To the left of our panel Project we find a small navigation menu from which we can
easily access the directories of our files or favorites
(Favorites), folders that filter all files of a specification
category. For example, by clicking on "All Models" they will be shown to us
all models that are currently in our project.

As soon as you start a project you will find yourself with the Asset folder which will always be present and will represent the folder above all in which all the assets will be found.
It would be a good habit to immediately create a hierarchy that initially contains at least the folders:

  • Textures
  • Scripts
  • Materials
  • Textures
  • Model fee

So you know immediately where to create or import files.

You will quickly learn that having many files in a project does not mean that they will all be part of the finished game. In fact, when we build the game, only the files actually used will be inserted in the game folders and not all those imported into the project.
You will assimilate this concept well when you notice that you will have a project of tens of Gb but a final build of a few hundred Mb (thankfully!). In fact, it may happen that you use "packages" downloaded from the Asset Store but only make use of small parts of them. Only the parts actually used (models, textures, scripts etc..) will be included in the build.

Move within the window scenes

At the top left is a small navigation bar with five buttons. They are used to move and interact with objects within the scene (in the scene window).

The buttons allow you to, in order from left to right:

  1. Pan the view
  2. Move the selected object
  3. Rotate the selected object
  4. Scale the selected object
  5. Deform the scale of the selected object
  • Mouse wheel: it is used to zoom the view of the scene.
  • Left mouse button: allows you to select objects in the scene.
  • Alt + left click: allows you to rotate the view around a point.
  • Right key: if held down, it enables the “fly mode”. In this mode, you can move around the scene using the W, A, S and D buttons, and you can rotate the view simply by moving the mouse.
  • Middle mouse button: It allows you to perform camera panning or move the view without rotating it. You can do the same by holding down Ctrl+Alt and use the left mouse button.
  • F-key: allows you to move the view to a single object. It will be very useful when you want to move quickly to an object in the scene that is very distant or out of your view. You can do the same operation with a Double Click of the mouse on an object of the Hierarchy.

A look at the Console panel

By pressing on the “Console” tab, we will switch from the Project panel to that… Console!

Like all panels, we can move it and place it where we like best.
This panel will show all the errors concerning your project (hopefully they will always be few).
It will be extremely useful when trying to fix a bug or to test if a script works correctly.
For example, you just need to write the code

Debug.Log("my text");

or

print("my text");

to see “my text” magically appear on your console!
Obviously we don't care about seeing a text that we wrote on the console, we will see the usefulness of this panel in the following lessons.
Keep in mind right now that this panel represents an output interface like the Game window, that is, it won't be possible to type text directly inside it, but it will be very useful as an output of what we will be interested in knowing while running our game.


When we install Unity, another program integrated with the engine, called MonoDevelop (in old versions) or Visual Studio Community (in newer versions).

So from the 2018.1 version of Unity we will no longer find MonoDevelop but the most professional Visual Studio.

Visual Studio Community is the free version of Visual Studio production program Microsoft, therefore different from that of Unity. Unity does not allow the writing of code within it, for this reason it relies on a script editor such as note Visual Studio. When we will double click on a script inside Unity, it will open on Visual Studio.

UNITY is an editor that allows the creation, positioning, assignment of the graphic part, etc… of the objects of our game.
VIsual Studio it is the editor that allows programming, i.e. the writing of code that will make the objects of our game move.

For simplicity we will define Visual Studio as a script editor. It comes with a normal text editor, but with a few more features. Keep in mind that it is possible to write scripts even with the simple Windows Notepad or any other text editor. The only difference is in the aids that the Visual Studio gives the developer, with advice while writing, error detection, syntax checking, use of colors to identify keywords, etc.

Visual Studio is therefore the script editor attached with Unity with which we will write the code of our game.

Information prethesis: what does “programming” mean?

As the word itself says, programming means preparing something for the future, in our case we can say that we will try to "give instructions to the computer which will then have to behave as we told it to do".

But let us remember that the computer is an inanimate object.
This makes it very different than if it were for example a person, to whom one could simply indicate:
“if it rains take an umbrella”. Or from our dog who can be taught a certain gesture or word which he will then interpret as "go to the doghouse" and will make him perform the action of going to the doghouse.

The computer is an object, like a pen, a table, a moped, etc. It's not an intelligent machine at all, there are no intelligent machines. There are only machines that are very fast in performing operations, a peculiarity that allows you to simulate a certain type of intelligence thanks to the possibility of performing billions of operations in less than a second so that it can find the most appropriate answer to a certain request by examining billions of possible answers in one millisecond.

The computer is a collection of pieces of plastic, copper and silicon. It is a car, like your moped, which if you want to "command" to go forward, you have to use the accelerator.
Your moped has its own way of interacting with you and understanding your commands, like every other car.
So, to command the computer that when you press a key it will do this or that thing you will need a language that it can understand.

The problem is that the only language that the computer understands is the one you wouldn't understand. It's a language made up of 1's and 0's which is very complicated and would be too time consuming if we tried to write it by hand.
Since the computer is a machine, it can do nothing but acknowledge the access or the off, precisely: 1 and 0. The language binary.

So, since the computer has the peculiarity of being very fast, even if many operations will be necessary, we could have it translate what we write in our language, into the language it can understand.

This procedure is called compilation and that's what Unity does automatically when we tell it to create the Build of our game.
Build literally means “build” or “construction”.

The Unity interface


But be careful not to get confused.

First di create a Build it will be a long time because it is what you do at the end of development or when you want to do some testing by creating an executable that you can test on other computers or pass on to other people.
A build is the final version of our game, the set of folders and files, including .exe files to run to start the game.

"Build" is the final operation that allows us to create the game that will be executable by the user.

During the development of our game we may test it at any time without necessarily having to create a build at each test, directly in the Unity editor, simply by pressing the key PLAY present in the center of the top bar of Unity.

The Unity interface

We will write in C# language on Visual Studio and then we will test our work by pressing the Play button on Unity.

The text that we will write in Visual Studio is commonly called code and the file of our project that we will be working on will be called source or more simply scripts.
A script is basically a file with the extension .cs (which stands for C Sharp) that can be assigned to a gameObject (object of the game) to make it do the things we want it to do.
The executable file that will "be born" from the compilation will be the compiled program, our game, ready to be run by anyone on their PC/console/mobile phone/Tablet etc...
It will therefore be sufficient to perform the build operation on Unity to transform our work into the executable and playable version by the user. This will only happen at the end of our work, once we have completed the development of the game or to do occasional tests during development.

compilation therefore we mean that process by which a program, written in a programming language, is translated into instructions that can be executed by the processor.

So, if we wrote this sentence on a script: “Pressing the right arrow key causes the model to move to the right” and assign it to a gameObject, It should work…
Too bad, however, that Unity does not understand Italian and (fortunately) only incorporates a less rich grammar than any spoken language. All programming languages ​​use the English language as a basis and therefore all instructions must be written in English. Don't worry if you don't speak English, if it were Italian or Ostrogothic, it wouldn't change anything, it wouldn't be easier or more difficult.

What we should write in English would be: "If right click pressed, X coordinate of the object increases by total" .
That would be better, but nothing will change and once again our compiler won't know how to translate what we wrote into machine understandable language and will send us an error. As mentioned, you need to use an adequate syntax made up of brackets and keywords.

The correct syntax would be IF(right.click=pressed){model.x=model.x+tot;}. That is, if the right mouse button is pressed, it increases the x coordinate of the model, so as to make it move.
We're almost there, but it's still not the correct syntax.
Whenever we want to tell the computer to do something only when a certain condition occurs (in our case the right button is pressed), we will encounter a little word that is surely the most important instruction of all, whatever language we use: SE. Well, the condition. Provided the right button is pressed, then do this or that.. In English: IF.

As you may have noticed there are some "equal signs" of parentheses, curly braces and a semicolon that we are not sure what they are doing. Those symbols are necessary for correct syntax, as if we were writing a sentence in Italian.
This is the syntax of the C# language (pronounced C Sharp) that Unity and Visual Studio will understand and will finally be able to compile, transforming our instructions from the C# language into the machine language that will create our program/game.
If on an Italian theme we wrote the sentence "perhaps:tomorrow!I'll go]to the(sea..." our teacher would give a good 2 in grammar (and perhaps she would have us seen by a specialist), because what we have written in Italian is not correct, even if the meaning is understood, there are some grammatical errors, therefore it is wrong. Same thing when we write in a programming language, the syntax must be the correct one, we can't invent it otherwise an error will be highlighted and the compilation will stop.

if ( condition ) { do this; }

Here we are, this is finally the correct grammar of the language we are speaking, the C#.

  1. First of all education IF which verifies the condition, i.e. if what we have written inside the round brackets either true or false.
  2. Just closed the parenthesis of the condition we find a curly brace that opens. Inside the curly braces is the code we want to execute when the condition will turn out to be true.
  3. The operation ends with a semicolon which always determines the end of the operation we want the computer to do.

    As you will have understood the symbology is very important, it will be necessary to use symbols such as equal, less, greater, etc…

Some examples to get familiar…

For example, if we wanted to perform an operation only when a player's score is 1000, we would write:

if(score == 1000){ ...do this... ;}

if instead we wanted to do the same thing when the score is equal to or greater than 1000, we would write something like this:

if(score >= 1000){ ...do this... ;}

where >= means “equal or greater”.

But why is it used to verify equality == and not simply =? That is, why use two equal symbols one after the other? We will see it in session 1.4 in which I explain the first control instruction in more detail, if ed else. But remember not to skip the previous sessions!

Final conclusions

Are you a little confused? It's normal. Keep going and don't be discouraged.
There is no better guide than experience. By doing the first tests you will begin to enter the right mentality and you will see that you will have everything clearer.
I remind you that, if you have not understood something, you can easily write a comment under each lesson.

add a comment of The Unity interface
Comment sent successfully! We will review it in the next few hours.

End of content

No more pages to load