Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Hands-On Unity 2022 Game Development - Third Edition
Hands-On Unity 2022 Game Development - Third Edition

Hands-On Unity 2022 Game Development: Learn to use the latest Unity 2022 features to create your first video game in the simplest way possible, Third Edition

By Nicolas Alejandro Borromeo
€26.99 €17.99
Book Oct 2022 712 pages 3rd Edition
eBook
€26.99 €17.99
Print
€33.99
Subscription
€14.99 Monthly
eBook
€26.99 €17.99
Print
€33.99
Subscription
€14.99 Monthly

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Oct 31, 2022
Length 712 pages
Edition : 3rd Edition
Language : English
ISBN-13 : 9781803236919
Category :
Table of content icon View table of contents Preview book icon Preview Book

Hands-On Unity 2022 Game Development - Third Edition

Creating a Unity Project

In this chapter, we will learn how to install Unity and create a project with Unity Hub, a tool that manages different Unity installations and projects, among other tasks. Unity Hub gives easy access to community blogs, forums, resources, and learning portals; it also manages your licenses, and allows you to change the building platform before opening the project on top of managing different installs and projects.

Specifically, we will examine the following concepts in this chapter:

  • Installing Unity
  • Creating projects

Let’s start by talking about how to get Unity up and running.

Installing Unity

We’ll begin with a simple but necessary first step: installing Unity. It seems like a straightforward first step, but we can discuss the proper ways to do this. In this section, we will be looking at the following concepts:

  • Unity’s technical requirements
  • Unity versioning
  • Installing Unity with Unity Hub

First, we will discuss what is necessary to run Unity on our computers.

Unity’s technical requirements

To run Unity 2022, your computer will need to meet the following operating system requirements:

  • If you use Windows, you need Windows 7 Service Pack 1 or greater, Windows 10, or Windows 11. Unity will run only on 64-bit versions of those systems; there is no 32-bit support unless you are willing to work with Unity versions before 2017.x, but that’s outside the scope of this book.
  • For Mac, you need Big Sur 11.0 to run Apple silicon versions of the editor. In any other case, you can run Intel versions of the editor from High Sierra 10.13 or superior.
  • For Linux, you need exactly Ubuntu 20.04, 18.04, or CentOS 7.

Regarding the CPU, these are the requirements:

  • Your CPU needs to support 64 bits
  • Your CPU needs to support SSE2 (most CPUs support it)
  • In the case of Macs with Apple silicon, M1 or above is needed

Finally, regarding graphics cards, these are the supported ones:

  • On Windows, we need a graphics card with DirectX 10, 11, or 12 support (most modern GPUs support it)
  • On Mac, any Metal-capable Intel or AMD GPU will be enough
  • On Linux, OpenGL 3.2 or any superior version, or a Vulkan-compatible card from Nvidia and AMD is supported

Now that we know the requirements, let’s discuss the Unity installation management system.

Unity versioning

Unity releases a new major version each year—at the time of writing, 2022.1—and during that year it receives an update with new features, which is planned to be 2022.2 at the time of writing this book. Near the end of the year or during the beginning of the next one, an LTS (long-term support) version is released, which will be 2022.3 for this edition of the book, marking the end of new features being added to that year’s version of the engine. After that, the next year’s edition of the engine is released, and the cycle repeats.

LTS versions have the benefit that they are planned to be updated bi-weekly with bug fixes for 2 years, while new major versions of Unity release. That’s the reason most companies stick to LTS versions of the engine: because of its stability and long-term support. In this book we will be using 2022.1 just to explore the new features of the engine, but consider sticking to LTS versions when developing commercial game titles.

Considering this, you may need to have several versions of Unity installed in case you work on different projects made with different versions. You may be wondering why you can’t just use the latest version of Unity for every project, but there are some problems with that.

In newer versions of Unity, there are usually lots of changes to how the engine works, so you may need to rework lots of pieces of the game to upgrade it, including third-party plugins. It can take lots of time to upgrade the whole project, and that can push the release date back. Maybe you need a specific feature that comes with an update that will help you. In such a case, the cost of upgrading may be worthwhile. For projects that are maintained and updated for several years, developers are used to updates only to the latest LTS versions of the editor, although this policy may vary from case to case.

Managing different projects made with different Unity versions, and installing and updating new Unity releases, all used to be a huge hassle. Thus, Unity Hub was created to help us with this, and it has become the default way to install Unity. Despite this, it is not necessary for installing Unity, but we will keep things simple for now and use it. Let’s look closer into it.

Installing Unity with Unity Hub

Unity Hub is a small piece of software that we will install before installing Unity. It centralizes the management of all your Unity projects and installations. You can get it from the official Unity website. The steps to download it change frequently, but at the time of writing this book, you need to do the following:

  1. Go to unity.com.
  2. Click on the Get started button, as shown in the following screenshot:

Figure 1.1: The Get started button on Unity’s website

  1. Click on the Student and hobbyist tab; then, under the Personal section, click on the Get started button, as illustrated in the following screenshot:

Figure 1.2: Choosing an individual/free license

  1. Scroll down to the section saying 1. Download the Unity Hub and click on the Download button according to your operating system. For Windows, click Download for Windows, and for Mac, click on Download for Mac. For Linux, there is an Instructions for Linux button with further info about how to install on that platform, but we won’t be covering Unity in Linux in this book:

Figure 1.3: Starting the download

  1. Execute the downloaded installer.
  2. Follow the instructions of the installer, which will mostly be clicking Next all the way to the end.

Now that we have Unity Hub installed, we must use it to install a specific Unity version. You can do this with the following steps:

  1. Start Unity Hub.
  2. If prompted to install a Unity version and/or create a license, please skip these steps with the corresponding Skip buttons (which may vary according to the Unity Hub version). This way to install Unity and licenses is only available the first time you run Unity Hub, but we are going to learn the way to do this that works after the first time.
  3. Log in to your account by clicking on the “person” icon at the top-left part of the window and selecting Sign in:

Figure 1.4: Signing into Unity Hub

  1. Here, you also have the option to create a Unity account if you haven’t already, as illustrated in the link labeled create one that appears in the Unity login prompt in the following screenshot:

Figure 1.5: Logging into Unity Hub

  1. Follow the steps on the installer and then you should see a screen like the one in the next image. If it is not the same, try clicking the Learn button at the top-left part of the screen:

Figure 1.6: The Unity Hub window

  1. Click on the Installs button and check if you have Unity 2022 listed there.
  2. If not, press the Install Editor button at the top-right corner. This will show a list of Unity versions that can be installed from here:

Figure 1.7: Unity versions available to install

  1. You will see three tabs here. Official releases contains the latest versions of each major release already released. Pre-releases contains alpha and beta releases of Unity, so you can participate in these programs and test new features before they are officially released. Archive contains a link to the Unity Download Archive that contains every single Unity version released. For example, the official release at the moment of writing this is 2022.1.20, but the project is being developed in 2022.1.14, so you can install the correct version from the archive.
  2. Locate Unity 2022.1 in the Official releases tab.
  3. Click on the Install button at the right of Unity 2022.1.XXf1, where XX will vary according to the latest available version. At the moment of writing this book we are using 2022.1.14f1. You might need to scroll down to find this version. If not present, install the latest 2022 version available (for example, 2022.2.XX or 2022.3.XX). Newer versions might vary of what is seen in the book, if you find the images of the book being too different consider looking for Unity 2022.1.14 in the archive.
  4. A modules selection window will show up. Make sure the Visual Studio feature is checked. While this program is not needed to work in Unity, we will be using it later in the book. If you already have a C# IDE installed, feel free to skip it.
  5. Now, click the Continue button:

Figure 1.8: Selecting Visual Studio

  1. Accept Visual Studio’s terms and conditions and then click Install:

Figure 1.9: Accepting Visual Studio’s terms and conditions

It is important to note that Visual Studio is the program we will use in Chapter 5, Introduction to Scripting with C# and Visual Scripting, to create our code. We do not need the other Unity features right now, but you can go back later and install them if you need them.

  1. You will see the selected Unity version downloading and installing. Wait for this to finish. If you don’t see it, click the Downloads button to reopen it:

Figure 1.10: Currently active Unity Hub downloads

  1. If you decided to install Visual Studio, after Unity has finished installing, the Visual Studio Installer will automatically execute. It will download an installer that will download and install Visual Studio Community:

Figure 1.11: Installing Visual Studio

  1. To confirm everything worked, you must see the selected Unity version in the list of Installs of Unity Hub:

Figure 1.12: Available Unity versions

Now, before using Unity, we need to acquire and install a free license to make it work by doing the following:

  1. Click the Manage licenses button at the top-right corner of the Unity Hub. If you don’t see it, click your account icon at the top-left corner and click Manage licenses there:

Figure 1.13: The Manage licenses button to press in order to acquire a free license

  1. Click the Add button in the Licenses list window:

Figure 1.14: The Licenses list window’s Add button

  1. Click the Get a free personal license button:

Figure 1.15: Option to get a free personal license

  1. Read and accept the terms and conditions if you agree with them by clicking the Agree and get personal edition license button:

Figure 1.16: The button to accept the terms and conditions

Remember that the preceding steps may be different in new Unity Hub versions, so just try to follow the flow that Unity designed—most of the time, it is intuitive.

Now it is time to create a project using Unity.

Creating projects

Now that we have Unity installed, we can start creating our game. To do so, we first need to create a project, which is basically a folder containing all the files that your game will be composed of. These files are called assets and there are different types of them, such as images, audio, 3D models, script files, and so on. In this section, we will see how to manage a project, addressing the following concepts:

  • Creating a project
  • Project structure

Let’s learn first how to create a blank project to start developing our project.

Creating a project

As with Unity installations, we will use the Unity Hub to manage projects. We need to follow these next steps to create one:

  1. Open the Unity Hub and click on the Projects button, and then click on New project:

Figure 1.17: Creating a new project in Unity Hub

  1. Pick the 3D (URP) template as we will be creating a 3D game with simple graphics, prepared to run on every device Unity can be executed on, so the Universal Render Pipeline (or URP) is the better choice for that. In Chapter 10, Materials and Effects with URP and Shader Graph, we will be discussing exactly why.
  2. If you see a Download template button, click it; if not, that means you already have the template:

Figure 1.18: Downloading the 3D URP template

  1. Choose a Project name and a Location, and click Create project:

Figure 1.19: Selecting the Universal Render Pipeline template

  1. Unity will create and automatically open the project. This can take a while, but after that you will see a window similar to the one in the following image. You might see the dark-themed editor instead, but for better clarity we will use the light theme throughout the book. Feel free to keep the dark theme:

Figure 1.20: The Unity Editor window

  1. Close the window, then go back to Unity Hub and pick the project from the list to open it again:

Figure 1.21: Reopening the project

Now that we have created the project, let’s explore its structure.

Project structure

We have just opened Unity, but we won’t start using it until the next chapter. Now, it’s time to see how the project folder structure is composed. To do so, we need to open the folder in which we created the project. If you don’t remember where this is, you can do the following:

  1. Right-click the Assets folder in the Project panel, located at the bottom part of the editor.
  2. Click the Show in Explorer option (if you are using a Mac, the option is called Reveal in Finder). The following screenshot illustrates this:

Figure 1.22: Opening the project folder in Explorer

  1. Then, you will see a folder structure similar to this one (some files or folders may vary):

Figure 1.23: Unity project folder structure

If you want to move this project to another PC or send it to a colleague, you can just compress all those files and send it to them as a ZIP file, but not all the folders are necessary all of the time. The important folders are Assets, Packages, and ProjectSettings. Assets will hold all the files we will create and use for our game, so this is a must. We will also configure different Unity systems to tailor the engine to our game; all the settings related to this are in the ProjectSettings and UserSettings folders. Finally, we will install different Unity modules or packages to expand its functionality, so the Packages folder will hold which ones we are using.

It’s not necessary to copy the rest of the folders if you need to move the project elsewhere or add it to any versioning system, but let’s at least discuss what the Library folder is, especially considering it’s usually a huge size. Unity needs to convert the files we will use to its own format in order to operate, and an example would be audio and graphics. Unity supports MPEG Audio Layer 3 (MP3), Waveform Audio File Format (WAV), Portable Network Graphics (PNG), and Joint Photographic Experts Group (JPG) files (and much more), but prior to using them, they need to be converted to Unity’s internal formats, a process called Importing Assets. Those converted files will be in the Library folder. If you copy the project without that folder, Unity will simply take the original files in the Assets folder and recreate the Library folder entirely. This process can take time, and the bigger the project, the more time involved.

Keep in mind that you want to have all the folders Unity created while you are working on the project, so don’t delete any of them while you work on it, but if you need to move an entire project, you now know exactly what you need to take with you.

Summary

In this chapter, we reviewed how the Unity versioning system works. We also saw how to install and manage different Unity versions using Unity Hub. Finally, we created and managed multiple projects with the same tool. We will use Unity Hub a lot, so it is important to know how to use it initially. Now, we are prepared to dive into the Unity Editor.

In the next chapter, we will start learning the basic Unity tools to author our first level prototype.

Join us on Discord!

Read this book alongside other users, Unity game development experts, and the author himself.

Ask questions, provide solutions to other readers, chat with the author via Ask Me Anything sessions, and much more.

Scan the QR code or visit the link to join the community.

https://packt.link/handsonunity22

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Create the game prototype and learn the fundamentals of Unity editor to build scenes, objects and import objects
  • Add interactivity, win/lose conditions, sound, graphics and artificial intelligence using C# and visual scripting
  • Improve the game graphics, user interface, add visual effects and animations using Animator, Cinemachine, and Timeline

Description

Unity is a cross-platform game engine that provides you with powerful but simple-to-use features to solve the most common problems in Game Development, such as rendering, animation, physics, sound, and effects. You’ll learn to use these features to create simple but complete games (and all the nuances needed to handle Unity). Complete with hands-on tutorials and projects, this book will teach you to use the Unity game engine, create C# and visual scripts, integrate graphics, sound, and animations, and manipulate physics to create interesting mechanics for your game. You’ll then code a simple AI agent to challenge the user and work with profiling tools to ensure code efficiency. Finally, you'll work with Unity's AR tools to create AR experiences for 3D apps and games before publishing them to the world. If you are interested in creating impressive, commercial-quality games that are playable on a variety of platforms, then you’ve come to the right place.

What you will learn

Build a game prototype that includes gameplay, player and non-player characters, assets, animations, and more Set up and navigate the game engine to dive into the Unity Editor and discover unique and new features released in 2022 Learn both C# and Visual Scripting to customize player movements, the user interface, and game physics Apply shaders to improve your game graphics using Shader Graph and Universal Render Pipeline (URP) Create win-lose conditions for the game by using design patterns such as Singleton and Event Listeners Implement Game AI to build a fully functional enemy capable of detecting and attacking the player Debug, test, optimize, and create an executable version of the game to share with your friends

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Buy Now

Product Details


Publication date : Oct 31, 2022
Length 712 pages
Edition : 3rd Edition
Language : English
ISBN-13 : 9781803236919
Category :

Table of Contents

23 Chapters
Preface Chevron down icon Chevron up icon
Creating a Unity Project Chevron down icon Chevron up icon
Editing Scenes and Game Objects Chevron down icon Chevron up icon
Grayboxing with Terrain and ProBuilder Chevron down icon Chevron up icon
Importing and Integrating Assets Chevron down icon Chevron up icon
Introduction to C# and Visual Scripting Chevron down icon Chevron up icon
Implementing Movement and Spawning Chevron down icon Chevron up icon
Physics Collisions and Health System Chevron down icon Chevron up icon
Win and Lose Conditions Chevron down icon Chevron up icon
Implementing Game AI for Building Enemies Chevron down icon Chevron up icon
Materials and Effects with URP and Shader Graph Chevron down icon Chevron up icon
Visual Effects with Particle Systems and Visual Effect Graph Chevron down icon Chevron up icon
Lighting Using the Universal Render Pipeline Chevron down icon Chevron up icon
Full-Screen Effects with Post-Processing Chevron down icon Chevron up icon
Sound and Music Integration Chevron down icon Chevron up icon
User Interface Design Chevron down icon Chevron up icon
Creating a UI with the UI Toolkit Chevron down icon Chevron up icon
Creating Animations with Animator, Cinemachine, and Timeline Chevron down icon Chevron up icon
Optimization with Profiler, Frame Debugger, and Memory Profiler Chevron down icon Chevron up icon
Generating and Debugging an Executable Chevron down icon Chevron up icon
Augmented Reality in Unity Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Filter icon Filter
Top Reviews
Rating distribution
Empty star icon Empty star icon Empty star icon Empty star icon Empty star icon 0
(0 Ratings)
5 star 0%
4 star 0%
3 star 0%
2 star 0%
1 star 0%

Filter reviews by


No reviews found
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.