1: posts
Reading ModeRO
$ cat 20200705_unityinst.md

#Setting up Unity on Linux

Date:2020-07-05 (Sun)
>Installing Unity Hub and the editor, activating a license, and testing the setup with a small C# script.

I’d wanted to learn Unity for a while and finally got around to installing it.
These are my notes from the initial setup through running a small Hello World example.
I’m a beginner at this, so there may be things I’ve missed.

ℹ️ Info: In this case, we will be dealing with environment setup for Ubuntu 18.04 LTS.

##In this article

  • Setting up Unity
  • Writing a test program

##Setting up Unity

It seems that you need to install something called Unity Hub before using Unity (maybe there are other ways too).
First, access the following URL and click the "Download Unity Hub" button.

The downloadable file is in the "Unity Hub.appimage" format.
This seems to be a universally usable executable file format for Linux.
For now, move this file to a folder that is easy to manage yourself, and right-click, select "Properties" → "Access Permissions" → check "Executable as a program".
If you've made it this far, double-click to launch Unity Hub.

Unity Hub appears to be a software that allows you to manage licenses and Unity versions in bulk.
When you launch it, you are first asked to register a user.
I won't explain it in detail, but I will create an account as instructed.

After logging in, this screen should be displayed.

Adding a license

###Adding a license

To use Unity, you need to add a license.
These were the Unity license options when I set this up:

  • Personal: free for individuals with annual revenue of $100,000 or less.
  • Plus: ¥4,400 per month, with an annual revenue limit of $200,000.
  • Pro: ¥16,500 per month, with no revenue limit.
  • Student: 18 years or older, no income limit
  • Enterprise: $22,000 per month, for large enterprises

As you can see from the image, even if you use it in apps that are paid to stream, in most cases, Personal seems to be fine.
There seem to be other features that can be used besides what is written above, but since I haven't used them yet, I don't know much about them, so I'll skip it.

Next, add a license.
Click "Verify New License" → "Unity Personal" → "Do not use Unity for business purposes" → "Run".

After adding the license

If the license is added successfully, it should display something like the above.

###Installing Unity

Next, install Unity.
This can also be done from Unity Hub.

Before that, you need to set the installation location for the Unity Editor.
Set the directory you want to install in the "General" → "Unity Editor Folder" section of the environment settings.
Press "Save" after setting it.

Setting the Installation Destination for the Editor

It's time to proceed with installing Unity.
From the arrow button in the top left corner, navigate to the settings screen, and when you press "Install," you will see the following screen.

Installation screen

When you press the "Install" at the top right, the following screen will be displayed.

Version selection screen

Probably selecting the latest LTS should do it.
Here, let's try installing "Unity 2019.4.2f1 (LTS)".

Next, choose the modules to install together.
Since you can add more later, I'll just select the minimum items that are necessary for now.
For now, let's try installing "Linux Build Support", "Documentation", and "Language packs Japanese".
Is Linux build support really necessary?

Installing Modules

Installation has begun.
Wait for it to finish as it will take some time.

Installing...

###Creating and opening a project

Move to the "Project" screen after the installation is complete.

Project page

Click "New Creation," set a default project name, and click "Create."

Creating a project

After a while, Unity will start.
In my case, it started up without any problems, but it seems that it can sometimes fail to start up because the dependency package is missing.
In that case, please refer to the following page to install the dependent packages.

If the launch is successful, the following window will pop up.

Starting Unity

Oh, it's a common Unity screen!laughs

##Writing a test program

Let's run a simple program to see how it works.

###Creating a C# script

Add the script to the "Assets" section in the "Project" tab at the bottom of the screen.
Right-click → "Create" → "C# Script" and click to create a script named "HelloWorld".
This created a C# file named "HelloWorld.cs".

Open the file and perform the following description, then save it.
I haven't used C#, but I can definitely understand this level, haha.

C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HelloWorld : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Hello World!");
    }

    // Update is called once per frame
    //void Update()
    // {

    // }
}

###Attaching the script to a GameObject

Add a GameObject below "SampleScene" in the "Hierarchy" tab in the top left corner.
Right-click and then press "Create Empty" to create a "GameObject".
Clicking it will display detailed information in the top-right "Inspector" tab.

First, change the name.
Let's start by calling it "HelloWorldObject".

Then, from "Add Component," locate the C# file "HelloWorld" that you just added and add it.
It should be in the following form.

Editing GameObject

It seems that Unity runs by linking the C# files created in this way to objects placed in 3D space.

###Running the program

Let's try running it.
Clicking the play mark at the top of the screen will run it.

Running HelloWorld

Look for “Hello World!” in the Console.

##Wrapping up

After wanting to try Unity for a while, I finally have a working installation.
I haven’t tried manipulating any 3D objects yet. That’s something I’d like to do next.

## Comments

"20200705_unityinst.md" [readonly]2L, 6925B
utf-8100%