Overview On Unity Basics

From Graal Bible

This section will go over the basic components of Unity explaining them briefly one by one.

Scenes:

The scene is basically where you build your game, it is where you add your environment, Gameobjects, designs, cameras and every part that makes up your game. When you create a new project, the default scene will contain a Camera and a Light.

Scene.png
GameObjects:

Everything you can think of that could be included in your game is a Gameobject (a character, a car, an environment, a light, a camera...). Think of a Gameobject as a container to which you add components, turning it into a character, a light, a sound… It is these components attached to your Gameobject that make up its functionalities, they do not accomplish much on their own (a Light is created by adding a light component to a Gameobject, a Cube has a collider component, equivalent to the setshape function in GraalScript, that gives it a specific volume/shape to the object).

Primitive Types:

Unity provides us with a number of Gameobjects created directly within Unity, they’re known as primitive types (Cube, Sphere, Capsule, Cylinder, Plane and Quad). They can easily be added to our scene and are usually used for testing purposes. (our first examples will be done using these Gameobjects, and as we go on we will use our own made up Gameobjects)

PrimitiveTypes.png
Camera:

The Camera is a Gameobject, that acts as the player's perspective of the world.

Components of a GameObject:

I will go over some of the most used components that we’ll see in the examples later on;

  • Transform: A default component for every Gameobject. It defines the Gameobject’s position, rotation and scale (how big it is) in the scene. It also enables parenting (which will be explained in a tutorial).
  • Rigidbody: The component that enables physics behavior for a Gameobject, it immediately add gravity to your Gameobject and make it a subject to forces. If a Collider component is also added to the Gameobject, it will be affected by collisions with other Gameobjects.
  • Collider: The component that gives the Gameobject a volume/shape (similar to setshape function in GraalScript). It is invisible and does not have to be the exact size of the Gameobject (you can give a rectangular shape to a car; it does not have to be the exact same shape). Unity provides us with primitive colliders (Box Collider, Sphere Collider and Capsule Collider).
  • Particle System: You can think of smoke coming out of an explosion as a particle system. They are made out of a big number of small images (meshes) moved around to create the desired effect.
  • Audio: Unity has a really powerful audio system, it simulates real life sounds. Sounds are emitted by different Gameobjects and received by the main camera. It takes into consideration the distance of the object and its effect on the sound and echo.
Prefabs:

A prefab is what you save your Gameobjects into. Making copies of a Gameobject is not optimized, if a certain change is needed, you will have to edit each individually. So instead you save them into a prefab, with their components and properties, and make instances of it. It acts as a template for your Gameobjects, edits done to the prefab will immediately be done on all the instances.

Asset:

An asset is any item you can use in your Unity project (Scenes, Prefabs, Cameras, Effects, Environment, Audio Files, Meshes, Animations...). They can be imported from outside Unity or created in Unity.

Asset Bundles:

AssetBundle is the archive file that contains all the non-code Assets (The AssetBundle cannot contain C# scripts). We will be using these types of assets to upload to the server since we code in GraalScript and not C#. We will extract the prefabs that they store, instantiate them and manipulate them with GraalScript.