Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Learning C# by Developing Games with Unity 6
Learning C# by Developing Games with Unity 6

Learning C# by Developing Games with Unity 6: Get to grips with coding in C# and build simple 3D games in Unity from the ground up , Eighth Edition

Arrow left icon
Profile Icon Harrison Ferrone
Arrow right icon
Early Access Early Access Publishing in Oct 2025
Mex$294.99 Mex$492.99
eBook Oct 2025 8th Edition
eBook
Mex$294.99 Mex$492.99
Paperback
Mex$430.99 Mex$615.99
Subscription
Free Trial
Arrow left icon
Profile Icon Harrison Ferrone
Arrow right icon
Early Access Early Access Publishing in Oct 2025
Mex$294.99 Mex$492.99
eBook Oct 2025 8th Edition
eBook
Mex$294.99 Mex$492.99
Paperback
Mex$430.99 Mex$615.99
Subscription
Free Trial
eBook
Mex$294.99 Mex$492.99
Paperback
Mex$430.99 Mex$615.99
Subscription
Free Trial

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
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Learning C# by Developing Games with Unity 6

Join our community on Discord!

https://packt.link/TdTYa

Pop culture loves to market computer programmers as outsiders, lone wolves, or geeky hackers – people who possess extraordinary mental gifts for algorithmic thought, little social IQ, and the odd anarchic bent. While this generalization is often incorrect (like all widescale generalizations), there is something to the idea that learning to code fundamentally changes the way you look at the world. The good news is that your naturally curious mind already wants to see patterns in the world, and you may even come to enjoy this new way of thinking. From the moment your eyes snap open in the morning to the last glimpse of your ceiling fan before you go to sleep, you’re unconsciously using analytical skills that directly translate to programming—you’re just missing the right language and syntax to map those life skills into code.You know your age, right? That’s a variable. When you cross the street, I...

Technical requirements

Sometimes it’s easier to start with what a thing isn’t, rather than what it is. The goal of this book isn’t to teach you everything there is to know about the Unity game engine or game development. By necessity, we’ll cover these topics at a basic level at the beginning of our journey, and in more detail in Chapter 6. These topics are included to provide a fun, accessible way to learn the C# programming language from the ground up, not an in-depth Unity tutorial. With programming as our main goal, there will be times when we opt for a code-based solution even though Unity may have a specific feature that does the same thing without any code. Don’t worry, I’ll point you in the right direction should you want to try them out later on in your game development journey!Since this book is aimed at complete beginners to programming, if you have no previous experience with either C# or Unity, you’re in the right place! If...

Getting started with Unity 6

If you don’t have Unity installed (or are running an earlier version), follow these steps to set up your environment:

  1. Head over to https://www.unity.com/.
  2. Select Download (shown in Figure 1.1):
Figure 1.1: Unity homepage

To provide a complete view of the Unity Editor, all our screenshots are taken in fullscreen mode. For color versions of all book images, use the following link: https://packt.link/7yy5V.

  1. This will take you to the Unity store page. Don’t feel overwhelmed by this—you can download Unity completely for free!

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.

  1. Scroll down to the How to get started section and download the Unity Hub application for either Windows or Mac, as shown in Figure 1.2. I’ll be using a Mac, but everything works the same on a Windows machine:

    Figure 1.2: Start creating with the Unity portal
  2. Once the download...

Using C# with Unity

Going forward, it’s important to think of Unity and C# as symbiotic entities. Unity is the engine where you’ll create scripts and GameObjects, but the actual programming takes place in another program called Visual Studio Code.

Setting up Visual Studio Code in Unity 6

Before continuing, it’s important that Visual Studio Code is set up as the script editor for your project. Go to the Unity menu | Settings | External Tools and check that External Script Editor is set to Visual Studio Code (or Windows):

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

Figure 1.13: Unity general preferences panel

We haven’t covered any basic programming concepts yet, but they won’t have a home until we know how to create an actual C# script in Unity. Let’s see how we can achieve this in the...

Exploring the documentation

The last topic we’ll touch on in this first foray into Unity and C# scripts is documentation. Not sexy, I know, but it’s important to form good habits early when dealing with new programming languages or development environments.

Accessing Unity’s documentation

Once you start writing scripts in earnest, you’ll be using Unity’s documentation quite often, so it’s beneficial to know how to access it early on. The Reference Manual will give you an overview of a component or topic, while specific programming examples can be found in the Scripting Reference.Every GameObject (an item in the Hierarchy window) in a scene has a Transform component that controls its Position, Rotation, and Scale. To keep things simple, we’ll just look up the camera’s Transform component in the Reference Manual:

  1. In the Hierarchy tab, select the Main Camera GameObject.
  2. Move over to the Inspector tab and click on the information icon...

Summary

We covered quite a bit of logistical information in this chapter, so I can understand if you’re itching to write some code. Starting new projects, creating folders and scripts, and accessing documentation are topics that are easily forgotten in the excitement of a new adventure. Just remember that this chapter has a lot of resources you might need in the coming pages, so don’t be afraid to come back and visit. Thinking like a programmer is like strengthening a muscle: the more you work it, the stronger it gets.In the next chapter, we’ll start laying out the theory, vocabulary, and main concepts you’ll need to prime your coding brain. Even though the material is conceptual, we’ll still be writing our first lines of code in the LearningCurve script. Get ready!

Pop quiz: Dealing with scripts

  1. What type of relationship do Unity and Visual Studio Code share?
  2. The Scripting Reference supplies example code in regard to using a particular Unity component or feature. Where can you find more detailed (non-code-related) information about Unity components?
  3. The Scripting Reference is a large document. How much of it do you have to memorize before attempting to write a script?
  4. When is the best time to name a C# script?

Don’t forget to check your answers against mine in the Pop Quiz Answers appendix to see how you did!

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Build a strong foundation in programming concepts and the C# language
  • Become confident in the fundamentals and features of Unity in line with Unity 6
  • Create a playable game prototype in Unity―a working first-person shooter game prototype
  • Purchase of the print or Kindle book includes a free PDF eBook

Description

It's the ability to write custom C# scripts for behaviors and game mechanics that really takes Unity the extra mile. That's where this book will help you as a new programmer! Harrison Ferrone, in this eighth edition of the bestselling series, will take you through the core concepts of programming and the C# language from scratch, while building an engaging and playable game prototype in Unity 6. You’ll get to grips with the fundamentals of object-oriented programming (OOP) and the Unity engine with lots of code samples, exercises, and tips to go beyond the book with your work. You’ll write C# scripts for simple game mechanics, perform procedural programming, and add complexity to your games by introducing intelligent enemies and damage-dealing projectiles. You’ll also explore the underlying mechanics of Unity game development, including game design, lighting basics, player movement, camera controls, collisions, and more with every passing chapter. Note: The screenshots in the book display the Unity editor in full-screen mode for a comprehensive view. You can easily reference color versions of images by downloading them from the GitHub repository or the graphics bundle linked in the book.

Who is this book for?

If you're a developer, programmer, hobbyist, or anyone who wants to get started with Unity and C# programming in a fun and engaging way, this book is for you. You'll still be able to follow along if you don't have programming experience, but knowing the basics will help you get the most out of this book.

What you will learn

  • Master programming fundamentals by breaking them into simple, digestible parts
  • Understand OOP concepts through clear explanations of C# code sample
  • Follow simple steps and examples to create and implement C# scripts in Unity 6
  • Divide your code into pluggable building blocks using interfaces, abstract classes, and class extensions
  • Grasp game design document basics, block out level geometry, add lighting, and animate simple objects
  • Create basic game mechanics, such as player controllers and shooting projectiles, using C#

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 30, 2025
Edition : 8th
Language : English
ISBN-13 : 9781805808701
Languages :
Tools :

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
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Oct 30, 2025
Edition : 8th
Language : English
ISBN-13 : 9781805808701
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Mex$85 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Mex$85 each
Feature tick icon Exclusive print discounts

Table of Contents

5 Chapters
Learning C# by Developing Games with Unity 6, Eighth Edition: Get to grips with coding in C# and build simple 3D games in Unity from the ground up Chevron down icon Chevron up icon
1 Getting to Know Your Environment Chevron down icon Chevron up icon
2 The Building Blocks of Programming Chevron down icon Chevron up icon
3 Diving into Variables, Types, and Methods Chevron down icon Chevron up icon
4Control Flow and Collection Types Chevron down icon Chevron up icon
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.