Unity Basics Course: Trying Out Unity

Unity is a powerful platform widely used for game development and real-time 3D content creation. In this course, you will learn the basic concepts of Unity, how to install the program, and how to create a simple project. Unity offers various tools and features to make it easy for users of all levels to access and learn.

1. What is Unity?

Unity is a cross-platform game engine that was first released in 2005 and has gained great popularity ever since. Unity supports both 2D and 3D game development and can be deployed across various platforms (PC, mobile, console, etc.). Its main features include powerful graphics rendering, a physics engine, and a user-friendly editor.

1.1 Features of Unity

  • Cross-platform support: Can be deployed to various platforms with a single development effort.
  • User-friendly interface: Intuitive UI and drag-and-drop functionality.
  • Strong community: Supported by extensive resources, tutorials, and forums.
  • Scalability and flexibility: Functionalities can be extended through various plugins and assets.
  • Free and paid versions: Offers a free version suitable for individuals or small projects.

2. Installing Unity

To use Unity, you first need to install it. Here are the steps to install:

2.1 Installing Unity Hub

Unity Hub is a tool used to manage the Unity Editor and projects. Follow these steps to install:

  1. Visit the official Unity website to download Unity Hub.
  2. Run the downloaded file to complete the installation.

2.2 Installing Unity Editor

Install the Unity Editor through Unity Hub:

  1. Run Unity Hub and go to the “Install” tab.
  2. Click the “Install New” button.
  3. Select the desired version of Unity and click “Next”.
  4. Select any necessary additional modules (e.g., Android Build Support) and complete the installation.

3. Creating Your First Project

Once the installation is complete, let’s create your first project:

3.1 Creating a New Project

  1. Navigate to the “Projects” tab in Unity Hub.
  2. Click the “New” button.
  3. Set the project name and save path, select a template, and then click the “Create” button.

3.2 Introduction to the Editor Interface

When you create a project, the Unity Editor opens. The editor interface consists of the following main elements:

  • Scene View: Shows the 3D space that composes the current scene.
  • Game View: Provides a preview of what the final game will look like when executed.
  • Hierarchy Panel: Lists all objects present in the current scene.
  • Inspector Panel: Allows you to adjust the properties of selected objects.
  • Project Panel: Manages all assets in the project.

4. Placing Objects

Now, let’s place your first object in the scene.

4.1 Adding a Basic Object

  1. Right-click in the Scene View and select “3D Object” > “Cube”.
  2. The cube is added to the scene and also appears in the Hierarchy Panel.
  3. You can adjust the cube’s position, rotation, and scale in the Inspector Panel.

5. Adding Scripts

In Unity, you can add functionality to objects by writing scripts in C#. Let’s write a simple script.

5.1 Creating a Script

  1. Right-click in the Project Panel and select “Create” > “C# Script”.
  2. Name the script and double-click to open it in Visual Studio or your IDE.

5.2 Writing a Basic Script

public class CubeRotation : MonoBehaviour
{
    void Update()
    {
        transform.Rotate(new Vector3(0, 1, 0) * Time.deltaTime * 50);
    }
}

The above code sets the cube to rotate around the y-axis every frame.

5.3 Applying the Script

  1. Drag the created script onto the cube object in the scene to apply it.
  2. Press the play button in the Game View to confirm that the cube is rotating.

6. Creating a Simple Game

Now, let’s create a simple game. The goal is for the cube’s color to change when the player clicks on it.

6.1 Writing a Color Change Script

using UnityEngine;

public class CubeColorChange : MonoBehaviour
{
    void OnMouseDown()
    {
        GetComponent().material.color = Random.ColorHSV();
    }
}

The script above sets the cube to change to a random color each time it is clicked.

6.2 Applying the Script

  1. Write the above script in a new C# script file and drag it onto the cube to apply it.
  2. Click the play button in the Game View again and click the cube. The color will change.

7. Adding UI

Let’s add UI to the game to display information to the user.

7.1 Creating a UI Canvas

  1. Right-click in the Hierarchy Panel and select “UI” > “Canvas” to create a canvas.
  2. Add “Text” under the canvas to enter the game title or instructions.

7.2 Styling the UI

You can change font size, color, etc., in the Inspector Panel. Additionally, you can adjust the position and alignment to arrange it nicely.

8. Building and Deploying

Once game development is complete, you can build the outcome for deployment. Let’s move on to the next steps.

8.1 Setting Up Build

  1. Select “File” > “Build Settings” from the top menu.
  2. Select the desired platform and click the “Switch Platform” button.
  3. Click the “Build” button to create the executable file.

8.2 Deployment

The completed game can be deployed according to the platform. For instance, for PC, you distribute the executable file, and for mobile, you package it as an APK file for distribution.

9. Conclusion

In this course, we learned basic concepts of Unity and how to create a simple game. Unity is a very powerful tool, and continuous learning is required to master more complex features and techniques. Utilize various tutorials and resources to explore more functionalities.

10. References

Thank you for reading the Unity course on this blog! We support your Unity learning journey.