Hands-On Unity  Game Development - Nicolas Alejandro Borromeo - E-Book

Hands-On Unity Game Development E-Book

Nicolas Alejandro Borromeo

0,0
29,99 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.
Mehr erfahren.
Beschreibung

Take your game development skills to the next level. Dive into the world of game creation confidently by elevating your game development skills. This book is your definitive and practical guide to unlocking the full potential of Unity 2023. Every chapter is designed to empower you to customize your own game, not just replicate what's in the book. This new edition includes immersive Augmented Reality (AR) experiences and performance optimization with Data-Oriented Technology Stack (DOTS).
From Scene Creation to seamless Assert Integration, dive into C# programming and Visual Scripting with step-by-step guidance for beginners. Implement dynamic gameplay elements, including movement, spawning, physics, and health systems. Delve deeper into the magic of Game AI through sensor-driven decision-making with Finite State Machines (FSMs). Elevate your visuals with materials, shaders, textures, and particle systems. Optimize performance with Profiler insights and debug your game for a polished final product.
Whether you're a beginner or a seasoned pro, this book will equip you with the skills needed to bring your game ideas to life.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Seitenzahl: 841

Veröffentlichungsjahr: 2024

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Hands-On Unity Game Development

Fourth Edition

Unlock the power of Unity 2023 and build your dream game

Nicolas Alejandro Borromeo

Juan Gabriel Gomila Salas

BIRMINGHAM—MUMBAI

Hands-On Unity Game Development

Fourth Edition

Copyright © 2024 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Senior Publishing Product Manager: Larissa Pinto

Acquisition Editor – Peer Reviews: Gaurav Gavas, Jane D'Souza

Project Editor: Namrata Katare

Content Development Editor: Ruksar Malik

Copy Editor: Safis Editing

Technical Editor: Kushal Sharma

Proofreader: Safis Editing

Indexer: Subalakshmi Govindhan

Presentation Designer: Pranit Padwal

Developer Relations Marketing Executive: Sohini Ghosh

First published: July 2020

Second edition: August 2021

Third edition: October 2022

Fourth edition: January 2024

Production reference: 1250124

Published by Packt Publishing Ltd.

Grosvenor House

11 St Paul’s Square

Birmingham

B3 1RB, UK.

ISBN 978-1-83508-571-4

www.packt.com

I would like to offer my heartfelt thanks to my father, who always encouraged my love for computers and games; I miss you dearly. To my wife, Edith, thank you for always reminding me what I’m capable of and also supporting me every step of the way of my career. We also want to thank our family and students that encouraged us and helped us become better instructors and teachers to help you learn easily.

– Nicolas Alejandro Borromeo

I want to thank our family and students that encouraged us and helped us become better instructors and teachers to help you learn easily.

– Juan Gabriel Gomila Salas

Contributors

About the authors

Nicolas Alejandro Borromeo is a game developer currently working for Unity Technologies as a Senior Software Development Consultant and Unity Certified Instructor in London. He is helping Unity clients with their projects all over the world. He started using Unity in 2008 and teaching it in 2012 in Universities and Education Institutes.

Juan Gabriel is the CEO of Frogames Formación, a Spanish e-learning platform. He has reached over half a million students worldwide, publishing around 200 courses.

About the reviewer

Jerry Medeiros is a seasoned professional with over a decade of hands-on experience in Immersive Technology, specializing in Games and Extended Reality. With a robust background in artificial intelligence, Jerry brings a unique perspective to the intersection of technology and interactive experiences. He holds a degree in Game Development, focusing on Interaction Design, and a Master of Computer Science with research expertise in artificial intelligence. Jerry is well-versed in cutting-edge technologies and their applications. Additionally, an MBA in Innovation further highlights his commitment to driving creative and forward-thinking solutions in the tech industry.

Learn more 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/unitydev

Contents

Preface

Who this book is for

What this book covers

To get the most out of this book

Get in touch

Section 1: Getting Started with Unity

Embark on Your Unity Journey

Installing Unity

Unity’s technical requirements

Unity versions

Installing Unity with Unity Hub

Creating projects

Creating a project

Project structure

Summary

Crafting Scenes and Game Elements

Manipulating scenes

The purpose of a scene

The Scene view

Adding our first GameObject to the scene

Navigating the Scene view

Manipulating GameObjects

GameObjects and components

Understanding components

Manipulating components

Understanding object Hierarchies

Parenting of objects

Possible uses

Managing GameObjects using Prefabs

Creating Prefabs

Prefab-instance relationship

Prefab variants

Saving scenes and projects

Summary

From Blueprint to Reality: Building with Terrain and ProBuilder

Defining our game concept

Creating a landscape with Terrain

Discussing Height Maps

Creating and configuring Height Maps

Authoring Height Maps

Adding Height Map details

Creating shapes with ProBuilder

Installing ProBuilder

Creating a shape

Manipulating the mesh

Adding details

Summary

Seamless Integration: Importing and Integrating Assets

Importing assets

Importing assets from the internet

Importing assets from the Asset Store

Importing assets from Unity packages

Integrating assets

Integrating terrain textures

Integrating meshes

Integrating textures

Configuring assets

Configuring meshes

Configuring textures

Assembling the scene

Summary

Section 2: Mastering Programming and Gameplay Mechanics

Unleashing the Power of C# and Visual Scripting

Introducing scripting

Creating scripts

Initial setup

Creating a C# script

Adding fields

Creating a visual script

Using events and instructions

Events and instructions in C#

Events and instructions in visual scripting

Using fields in instructions

Common beginner C# script errors

Summary

Dynamic Motion: Implementing Movement and Spawning

Implementing movement

Moving objects through Transform

Using Input

Understanding Delta Time

Implementing spawning

Spawning objects

Timing actions

Destroying objects

Using the new Input System

Installing the new Input System

Creating Input Mappings

Using Mappings in our scripts

Summary

Collisions and Health: Detecting Collisions Accurately

Configuring physics

Setting shapes

Physics object types

Filtering collisions

Detecting collisions

Detecting Trigger events

Modifying the other object

Moving with physics

Applying forces

Tweaking physics

Summary

Victory or Defeat: Win and Lose Conditions

Creating object managers

Sharing variables with the Singleton design pattern

Sharing variables with Visual Scripting

Creating managers

Creating Game Modes

Improving our code with events

Summary

Starting Your AI Journey: Building Intelligent Enemies for Your Game

Gathering information with sensors

Creating three-filter sensors with C#

Creating Three-Filters sensors with Visual Scripting

Debugging with gizmos

Making decisions with FSMs

Creating the FSM in C#

Creating transitions

Creating the FSM in Visual Scripting

Executing FSM actions

Calculating our scene’s NavMesh

Using Pathfinding

Adding the final details

Summary

Learn more on Discord

Section 3: Elevating Visuals, Effects, and Audio

Material Alchemy: Using URP and Shader Graph for Stunning Visuals

Introducing shaders and URP

Shader pipeline

Render pipeline and URP

URP built-in shaders

Creating shaders with Shader Graph

Creating our first Shader Graph

Using textures

Combining textures

Applying transparency

Creating vertex effects

Summary

Captivating Visual Effects: Harnessing Particle Systems and Visual Effect Graph

Introduction to particle systems

Creating a basic particle system

Using advanced modules

Creating fluid simulations

Creating a waterfall effect

Creating a bonfire effect

Creating complex simulations with Visual Effect Graph

Installing Visual Effect Graph

Creating and analyzing Visual Effect Graph

Creating a rain effect

Scripting Visual Effects

Summary

Enlightening Worlds: Illuminating Scenes with the Universal Render Pipeline

Applying lighting

Discussing lighting methods

Configuring ambient lighting with skyboxes

Configuring lighting in URP

Applying shadows

Understanding shadow calculations

Configuring performant shadows

Optimizing lighting

Understanding static lighting

Baking lightmaps

Applying static lighting to static objects

Summary

Immersive Realism: Achieving Fullscreen Effects with Post-Processing

Using post-processing

Setting up a profile

Using basic effects

Using advanced effects

High Dynamic Range (HDR) and depth map

Applying advanced effects

Summary

Harmonious Soundscapes: Integrating Audio and Music

Importing audio

Audio types

Configuring import settings

Integrating and mixing audio

Using 2D and 3D AudioSources

Using an Audio Mixer

Scripting audio feedback

Summary

Section 4: Designing User Interfaces, Animations and Advanced Concepts

Interface Brilliance: Designing User-Friendly UI

Understanding the Canvas and RectTransform

Creating a UI with the Canvas

Positioning elements with RectTransform

Canvas object types

Integrating assets for the UI

Creating UI controls

Creating a responsive UI

Adapting object positions

Adapting object sizes

Scripting the UI

Showing information in the UI

Programming the Pause menu

Summary

Next-Gen UI: Creating Dynamic Interfaces with UI Toolkit

Why learn how to use UI Toolkit?

Creating a UI with UI Toolkit

Creating UI Documents

Editing UI Documents

Creating UI Stylesheets

Making a responsive UI

Dynamic positioning and sizing

Dynamic scaling

Using relative positions

Summary

Animated Realities: Creating Animations with Animator, Cinemachine, and Timeline

Using skinning animation with Animator

Understanding skinning

Importing skeletal animations

Integration using Animation Controllers

Applying the Controller to your character

Using Avatar Masks

Scripting animations

Scripting player shooting animations

Scripting movement animations

Creating dynamic cameras with Cinemachine

Creating camera behaviors

Creating dolly tracks

Creating cutscenes with Timeline

Creating animation clips

Sequencing our intro cutscene

Summary

Performance Wizardry: Optimizing Your Game with Profiler Tools

Optimizing graphics

Introduction to graphics engines

Using Frame Debugger

Using batching

Other optimizations

Optimizing processing

Detecting CPU- and GPU-bound

Using the CPU Usage Profiler

General CPU optimization techniques

Optimizing memory

Memory allocation and the garbage collector

Using the Memory Profiler

Summary

From Prototype to Executable: Generating and Debugging Your Game

Building a project

Debugging the build

Debugging code

Profiling performance

Summary

AR/VR

Using AR Foundation

Creating an AR Foundation project

Using tracking features

Building for mobile devices

Building for Android

Building for iOS

Creating a simple AR game

Spawning the player and enemies

Coding the player and enemy behavior

Summary

Massive Worlds: Introduction to DOTS

Understanding what DOTS is

Creating our first DOTS game

Creating a DOTS project

Creating entities with subscenes

Creating components and bakers

Creating systems using Jobs and Burst

Debugging system jobs and queries

Creating gameplay in DOTS

Moving using input and tag components

Creating seeking missiles using component lookups

Destroying the character with entity command buffers

Dealing with errors in bursted code

Instantiating missiles with entity Prefabs

Making the camera follow our character

Exploring other DOTS features

Summary

Other Books You May Enjoy

Index

Landmarks

Cover

Index

Preface

I can vividly remember the trepidation I felt about telling my parents that I was going to study game development. At that time, in my region, this ambition was dismissed as juvenile and lacking in future prospects. However, my tenacity and determination led me to chase this dream relentlessly. Today, the game industry has grown exponentially, surpassing even the film industry in revenue.

Of course, following my dream was more difficult than I anticipated. Anyone with the same dream as me sooner or later realizes the complexity and depth of knowledge required in this field. Sadly, this steep learning curve leads many to give up, but I strongly believe that with the proper guidance and tools, you can make your career path easier. For me, mastering Unity was pivotal in streamlining my learning process. And this book is a culmination of that experience, aimed at easing your journey into the world of game development.

Welcome to this book about Unity 2023. This book will introduce you to the latest Unity features so that you can create your first video game in the simplest way possible. Unity offers an array of user-friendly yet powerful tools to address common game development challenges, such as rendering, animation, physics, sound, and effects. We will utilize all these features to create a simple but complete game, delving into all the intricacies of Unity.

By the end of this book, you will have all the skills necessary to use Unity effectively, allowing you to explore in depth various areas of game development that interest you, whether for building a professional career or simply for the joy of creating games as a hobby. Unity is a versatile tool for both professional and amateur projects, and it is being used every day by more and more people.

Unity’s utility extends beyond game creation; it’s a powerful platform for all kinds of interactive applications, from straightforward mobile apps to complex educational and training programs, often referred to as Serious Gaming. These applications harness cutting-edge technologies like Augmented and Virtual Reality. Therefore, while our primary focus here is game development, you are embarking on a learning journey that offers a spectrum of potential specializations.

Who this book is for

This book has been thoughtfully structured to cater to people from various backgrounds. If you have a basic understanding of Object-Oriented Programming (OOP) but are new to game development or have never used Unity, you’ll find this book a good introduction to both game development and Unity’s fundamental to advanced concepts. Even seasoned Unity developers looking to master the platform’s latest features will discover valuable insights in many sections of this book.

On the other hand, if you’re starting without any programming experience, this book is still highly accessible. Many chapters have been designed to be informative without requiring prior coding knowledge. These sections will equip you with a solid foundation for starting to learn how to code in Unity, making the learning curve much smoother than it would be otherwise. Once you’ve grasped the basics of coding, the scripting-focused chapters of this book will become increasingly beneficial. Additionally, with the introduction of Visual Scripting in Unity, those who prefer node-based scripting have an appealing alternative available.

What this book covers

Chapter 1, Embark on Your Unity Journey, teaches you how to install and set up Unity on your computer, as well as how to create your first project.

Chapter 2, Crafting Scenes and Game Elements, teaches you the concepts of Scenes and GameObjects, the Unity way to describe what your game world is composed of.

Chapter 3, From Blueprint to Reality: Building with Terrain and ProBuilder, is where we will be creating our first level layout, prototyping it with the Terrain and ProBuilder Unity features.

Chapter 4, Seamless Integration: Importing and Integrating Assets, is where we will be creating our first level layout, prototyping it with the Terrain and ProBuilder Unity features.

Chapter 5, Unleashing the Power of C# and Visual Scripting, is the first programming chapter of the book. We will learn how to create our first script using C# in the Unity way, and then we will explore how to do the same with Visual Scripting, the new node-based coding language of Unity.

Chapter 6, Dynamic Motion: Implementing Movement and Spawning, teaches you how to program the movement of your objects and how to spawn them. This chapter introduces the new Unity Input System. General programming knowledge is assumed from this point on.

Chapter 7, Collisions and Health: Detecting Collisions Accurately, teaches you how to configure the Physics settings of objects to detect when two of them collide and react to the collision, creating a health system, in this case.

Chapter 8, Victory or Defeat: Win and Lose Conditions, covers how to detect when the game should end, both when the player wins and loses.

Chapter 9, Starting your AI Journey: Building Intelligent Enemies for Your Game, covers creating a basic AI using several Unity features for creating challenging enemies in our game.

Chapter 10, Material Alchemy: Using URP and Shader Graph for Stunning Visuals, shows how to use one of the latest Unity render systems (Universal Render Pipeline, or URP) and how to create effects with the Shader Graph feature.

Chapter 11, Captivating Visual Effects: Harnessing Particle Systems and Visual Effect Graph, teaches you how to create visual effects such as water and fire using the two main Unity tools for doing so, Particle Systems and VFX Graph, and how to make scripts that control them according to what’s happening in the game.

Chapter 12, Enlightening Worlds: Illuminating Scenes with the Universal Render Pipeline, looks at lighting, which is a concept big enough to have its own chapter. Here, we will deepen our knowledge of the Universal Render Pipeline, specifically its lighting capabilities.

Chapter 13, Immersive Realism: Achieving Fullscreen Effects with Post-Processing, teaches you how to add a layer of effects on top of your scene graphics using the postprocessing feature of the Universal Render Pipeline to get that film effect most modern games have today.

Chapter 14, Harmonious Soundscapes: Integrating Audio and Music, covers a topic that is underestimated by most beginner developers; here we will learn how to properly add sound and music to our game, taking into consideration its impact on performance. This also covers how to script the sound.

Chapter 15, Interface Brilliance: Designing User-Friendly UI, looks at the User Interface (UI). Of all the graphical ways to communicate information to the user, the UI is the most direct one. We will learn how to display information in the form of text, images, and life bars using the Unity UI system, and also how to script the UI.

Chapter 16, Next-Gen UI: Creating Dynamic Interfaces with UI Toolkit, looks at UI Toolkit, which is the successor of Canvas, the UI system we learned about in the previous chapter. We will explore it to get ahead and be prepared for Unity’s use of this HTML-based toolkit in the future.

Chapter 17, Animated Realities: Creating Animations with Animator, Cinemachine, and Timeline, Cinemachine, and Timeline, takes us further than the static scene we have created so far. In this chapter, we will start moving our characters and creating cutscenes with the latest Unity features to do so, and how to script them.

Chapter 18, Performance Wizardry: Optimizing Your Game with Profiler Tools, discusses how making our game perform well is no easy task, but is certainly needed to release it. Here, we will be learning how to profile our game’s performance and tackle the most common performance issues.

Chapter 19, From Prototype to Executable: Generating and Debugging Your Game, teaches you how to convert your Unity project into an executable format to distribute it to other people and run it without Unity installed.

Chapter 20, AR/VR, teaches you how to create an AR application with Unity’s AR Foundation package, one of the most recent ways to create AR applications with Unity.

Chapter 21, Massive Worlds: Introduction to DOTS, teaches you how to start creating projects with DOTS, the new Unity technology that allows the creation of highly performant games to create complex gameplay involving thousands of objects on scene.

To get the most out of this book

You will be developing a full project through the chapters of this book, and while you can just read the chapters, I highly recommend you practice all the steps in this project as you advance through the book so you can get the experience needed to properly learn the concepts demonstrated here. The chapters have been designed so you can customize the game and not create the exact game shown in the book. However, I recommend not deviating too much from the main idea.

The project files have been split into a folder per chapter and have been designed in a cumulative way, each folder having just the new files introduced by the chapter or the changed ones. This means, for example, that if a file hasn’t changed since Chapter 1, you won’t find it in Chapter 2 onward; those chapters will just use the file introduced in Chapter 1. This allows you to see just what we changed in each chapter, easily identifying the needed changes, and if for some reason you can’t finish, for example, Chapter 3, you can just continue with Chapter 4’s steps on top of Chapter 3. Also note that Chapters 15 to 19 will have two versions of the files: the C# ones and the Visual Scripting ones.

Software/hardware covered in the book

OS requirements

Unity 2023.2

Windows, macOS X or Linux (any)

Visual Studio 2023 Community

Windows or macOS X (any)

XCode 15

macOS X

While we will see how to use XCode 15, it is not required for most of the chapters. Also, there are alternatives to Visual Studio in Linux, like Visual Studio Code.

If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

Download the example code files

The code bundle for the book is hosted on GitHub at https://github.com/PacktPublishing/Hands-On-Unity-2023-Game-Development-Fourth-Edition. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://packt.link/gbp/9781835085714.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. For example: “Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system.”

A block of code is set as follows:

<ui:Scrollerhigh-value"100"direction"Horizontal"value"42" />

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<ui:Scrollerhigh-value"100"direction"Horizontal"value"42" />

Bold: Indicates a new term, an important word, or words that you see on the screen. For instance, words in menus or dialog boxes appear in the text like this. For example: “Select System info from the Administration panel.”

Warnings or important notes appear like this.

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book’s title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you reported this to us. Please visit http://www.packtpub.com/submit-errata, click Submit Errata, and fill in the form.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit http://authors.packtpub.com.

Share your thoughts

Once you’ve read Hands-On Unity Game Development, Fourth Edition we’d love to hear your thoughts! Scan the QR code below to go straight to the Amazon review page for this book and share your feedback.

https://packt.link/r/1835085717

Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.

Download a free PDF copy of this book

Thanks for purchasing this book!

Do you like to read on the go but are unable to carry your print books everywhere?

Is your eBook purchase not compatible with the device of your choice?

Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.

Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application. 

The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily

Follow these simple steps to get the benefits:

Scan the QR code or visit the link below

https://packt.link/free-ebook/9781835085714

Submit your proof of purchaseThat’s it! We’ll send your free PDF and other benefits to your email directly

Section 1

Getting Started with Unity

Master the basics of the Unity editor, from creating a blank project to crafting scenes with both prototype and final graphics.

This section comprises the following chapters:

Chapter 1, Embark on Your Unity JourneyChapter 2, Crafting Scenes and Game ElementsChapter 3, From Blueprint to Reality: Building with Terrain and ProBuilderChapter 4, Seamless Integration: Importing and Integrating Assets

1

Embark on Your Unity Journey

In this chapter, we will learn how to install Unity and create a project with Unity Hub, a tool that manages different Unity versions 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 managing different installs and projects.

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

Installing UnityCreating projects

Let’s start by talking about how to get Unity up and running. If you already know how to install Unity, feel free to skip ahead to Chapter 2, Crafting Scenes and Game Elements. If you are already familiar with Unity’s editor, you can jump to Chapter 3, From Blueprint to Reality: Building with Terrain and ProBuilder, where we start creating the book’s project.

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 requirementsUnity versioningInstalling Unity with Unity Hub

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

Unity’s technical requirements

To run the Unity 2023 editor, your computer will need to meet the requirements specified here: https://docs.unity3d.com/2023.2/Documentation/Manual/system-requirements.html

Here is a summary of what’s specified in the link:

If you use Windows, you need Windows 10.7 version 21H1 (19043) or higher. 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.For Linux, you need exactly Ubuntu 20.04 or 22.04.

Regarding the CPU, these are the requirements:

Your CPU needs to support 64 bitsYour CPU needs to support SSE2 (most CPUs support it)In the case of Macs with Apple silicon, M1 or above is needed. For Intel Macs, any with x64 and SSE2 support will work.

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 enoughOn Linux, OpenGL 3.2 or any superior version, or a Vulkan-compatible card from Nvidia and AMD is supported

Note that these are not the requirements for a user to play your game, but for you to use the editor. For the requirements for a user to play your game, please read the following documentation: https://docs.unity.cn/ru/2021.1/Manual/system-requirements.html#player

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

Unity versions

At this book is being written, Unity announced a shift in their versioning system. The current release, Unity 2023.2, will be the final iteration of the 2023 series. The next version, which was supposed to be 2023.3 LTS, will instead be launched as Unity 6. This transition marks the end of the LTS (Long-Term Support) release cycle, which forced Unity to undertake several releases each year. Moving forward, we anticipate the sequential roll-out of Unity versions 6.1, 6.2, 6.3, and so forth, each offering a stable platform enriched with new features.

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 2023.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. In projects that require maintenance and updates over several years, developers typically adhere to the existing version, opting to upgrade only when a new update includes a necessary feature.

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:

Go to unity.com.Click on the PLANS AND PRICING button, as shown in the following screenshot:

Figure 1.1: The PLANS AND PRICING button on Unity’s website

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

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

Execute the downloaded installer.Follow the instructions of the installer, which will mostly involve 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:

Start Unity Hub.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 an alternative approach that works after the initial setup.Log in to your account by clicking on the Sign in button:

Figure 1.4: Signing in to Unity Hub

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 in to Unity Hub

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

Figure 1.6: The Unity Hub window

Click on the Installs button and check if you have Unity 2023 listed there.If not, click the Install Editor button in 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

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, which contains every single Unity version released. For example, the official release at the time of writing this is 2023.2.4f1, but if you see a newer version instead, you can install the correct version from the archive.Locate Unity 2023.2 in the Official releases tab (or, if you can’t find it, in the Archives tab).Click on the Install button at the right of Unity 2023.2.XXf1, where XX will vary according to the latest available version. The Archive contains a link to the Unity Download Archive, which houses every version of Unity ever released. As of the writing of this text, the official release is 2023.2.4f1, but should you encounter a newer version, you can install the correct version from the archive.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.Now, click the Continue button:

Figure 1.8: Selecting Visual Studio

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, Unleashing the Power of 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.

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

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

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 that we have installed Unity and Visual Studio through Unity Hub on our computer, before using Unity, we need to acquire and install a free license to make it work by doing the following:

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

Figure 1.13: The Add licenses button to click in order to acquire a free license

Click the Add button in the Licenses list window:

Figure 1.14: The Licenses list window’s Add button

Click the Get a free personal license button:

Figure 1.15: Option to get a free personal license

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

With that, we now have a valid license to use Unity in our account. 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 projectProject structure

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

Creating a project

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

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

Figure 1.17: Creating a new project in Unity Hub

Note that if you have more than one version of Unity installed through Unity Hub, you may need to select the appropriate version from the drop-down menu at the top of the UI to make sure you use the 2023.1 version you installed before.

Figure 1.18: Picking the proper Unity version

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 URP (or Universal Render Pipeline) is the better choice for that. In Chapter 10, Material Alchemy: Using URP and Shader Graph for Stunning Visuals, we will be discussing exactly why.If you see a Download template button, click it; if not, that means you already have the template:

Figure 1.19: Downloading the 3D URP template

I still remember the first template project I saw in Unity 2.6 back in 2009, before the Unity version numbers matched the release year. It was an island that showcased the Terrain and Water systems. It had flamingos that avoided you when you were close, and it was a lot of fun to walk around. Sadly, the template project we chose won’t be as memorable as that one, but it’s still a good one to start.

Choose a project name and a location, and click Create project:

Figure 1.20: Selecting the Universal Render Pipeline template

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 screenshot. 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.21: The Unity Editor window

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

Figure 1.22: 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:

Right-click the Assets folder in the Project panel, located at the bottom part of the editor.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.23: Opening the project folder in Explorer

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

Figure 1.24: Unity project folder structure

Now that we have created and opened our first URP project using Unity Hub, we can find it again in the future in the Projects tab of Unity Hub. From there, we can open it again at any time.

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 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 ProjectSettingsand UserSettings folders. Finally, we will install different Unity modules or packages to expand its functionality, so the Packages folder will hold the 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 a 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; an example is 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 is 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 begin exploring basic Unity tools, laying the groundwork for authoring our first level prototype.

Learn more 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/unitydev