
Learning C# by Developing Games with Unity
By :

If you don’t have Unity installed (or are running an earlier version), follow these steps to set up your environment:
Figure 1.1: Unity homepage
To provide a complete view of the Unity editor, all our screenshots are taken in full-screen mode. For color versions of all book images, use the link below: https://packt.link/7yy5V.
If the Unity homepage looks different for you than what you can see in Figure 1.1, you can go directly to https://store.unity.com.
Figure 1.2: Start creating with the Unity portal
Figure 1.3: Install Unity Editor window
Figure 1.4: Install wizard
Figure 1.5: Unity Hub Installs panel
Figure 1.6: Add Unity version pop-up window
Figure 1.7: Adding install modules
When the installation is complete, you’ll see a new version in your Installs panel, as follows:
Figure 1.8: Installs tab with Unity versions
You can find additional information and resources about the Unity Hub application at https://docs.unity3d.com/hub/manual/index.html.
There’s always a chance of something going wrong, so be sure to check the following section if you’re using macOS Catalina or later, which has been known to throw up issues.
If you’re working on a Mac with OS Catalina or later, there is a known issue when using some versions of Unity Hub to install Unity. If this is the case for you, take a deep breath, go to the Unity download archive, and grab the 2023 version you need (https://unity3d.com/get-unity/download/archive). Remember to use the Downloads (Mac) or Downloads (Win) option instead of the Unity Hub download:
Figure 1.9: Unity download archive
Once the installer application downloads, open it up and follow the setup instructions! All of the examples and screenshots for this book were created and captured using Unity 2023.1.5f1. If you’re using a newer version, things might look slightly different in the Unity Editor, but this shouldn’t affect your following along.
Now that Unity Hub and Unity 2023 are installed, it’s time to create a new project!
Launch the Unity Hub application, which is your staging area—you can see a list of all your projects and Unity versions and access learning resources and community features here. Then, take the following steps:
Figure 1.10: Unity Hub Projects panel
Hero Born
Figure 1.11: Unity Hub with New project configuration popup
With the project created, you’re all set to explore the Unity interface! You can re-open your project anytime from the Projects panel in Unity Hub, but if your computer is running a little slow with both Unity and Unity Hub open, feel free to close Unity Hub.
When the new project finishes initializing, you’ll see the glorious Unity Editor! I’ve marked the important tabs (or windows, if you prefer) in Figure 1.12:
Figure 1.12: Unity interface
This is a lot to take in, so we’ll look at each of these panels in more detail:
If any of these windows get closed by accident, you can re-open them anytime from the Unity menu > Window > General. You can find more in-depth breakdowns of each window’s functionality in the Unity docs at: https://docs.unity3d.com/Manual/UsingTheEditor.html.
Before continuing, it’s important that Visual Studio is set up as the script editor for your project. Go to the Unity menu > Preferences > External Tools and check that External Script Editor is set to Visual Studio for Mac (or Windows):
Figure 1.13: Changing External Script Editor to Visual Studio
As a final tip, if you want to switch between light and dark modes, go to the Unity menu > Preferences > General and change Editor Theme:
I know that was a lot to process if you’re new to Unity, but rest assured that any instructions going forward will always reference the necessary steps. I won’t leave you wondering what button to push. With that out of the way, let’s start creating some actual C# scripts.
Change the font size
Change margin width
Change background colour