Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Design Patterns with Unity

You're reading from  Learning Design Patterns with Unity

Product type Book
Published in May 2024
Publisher Packt
ISBN-13 9781805120285
Pages 676 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Harrison Ferrone Harrison Ferrone
Profile icon Harrison Ferrone
Toc

Table of Contents (23) Chapters close

Preface 1. Priming the System 2. Managing Access with the Singleton Pattern 3. Spawning Enemies with the Prototype Pattern 4. Creating Items with the Factory Method Pattern 5. Building a Crafting System with the Abstract Factory Pattern 6. Assembling Support Characters with the Builder Pattern 7. Managing Performance and Memory with Object Pooling 8. Binding Actions with the Command Pattern 9. Decoupling Systems with the Observer Pattern 10. Controlling Behavior with the State Pattern 11. Adding Features with the Visitor Pattern 12. Swapping Algorithms with the Strategy Pattern 13. Making Monsters with the Type Object Pattern 14. Taking Data Snapshots with the Memento Pattern 15. Dynamic Upgrades with the Decorator Pattern 16. Converting Incompatible Classes with the Adapter Pattern 17. Simplifying Subsystems with the Façade Pattern 18. Generating Terrains with the Flyweight Pattern 19. Global Access with the Service Locator Pattern 20. The Road Ahead 21. Other Books You May Enjoy
22. Index

To get the most out of this book

My north star is always making my content accessible to as many people as possible, which means I naturally try and keep prerequisites and barriers to entry fairly low or non-existent. However, design patterns are an intermediate programming topic, which means you need some foundational competencies to get going and feel confident with the material being presented.

Whatever brought you here, we need to lay out some basic requirements for getting the best possible experience from reading this book, so we’re all on the same page. Here’s what you’ll need before getting started:

  • Know how to write C# and its basic language components like variables, types, access modifiers, and control flow.
  • Understand and use Object-Oriented Programming concepts like classes, objects, interfaces, generics, events, delegates, inheritance, and encapsulation.
  • Be comfortable with Unity and the Unity editor, including navigation, creating scripts, and adding objects to the scene. You should also be comfortable with coroutines and basic Unity events like Awake, Start, and Update.

I don’t want all of this to sound discouraging, so just know that if you’ve been playing around with Unity and C# for a few months, maybe watched some tutorials, or even made a simple playable prototype or two - you can absolutely continue reading. This book is a reference, which means you’ll likely need to revisit chapters more than once to get things cemented in your mind. Don’t feel obligated to read the book in sequence either – the right tool for the job is the mainstay of everything you’ll learn here.

You’ll also need the current version of Unity installed on your computer—2023 or later is recommended. All code examples have been tested with Unity 2023.1 and should work with future versions without issues.

Requirements for the chapter exercises

Version

Unity

2023.1 or later

Visual Studio

2019 or later

Before starting, check that your computer setup meets the Unity system requirements at https://docs.unity3d.com/2023.1/Documentation/Manual/system-requirements.html.

Download the example code files

The code bundle for the book is hosted on GitHub at https://github.com/PacktPublishing/C-Design-Patterns-with-Unity-First-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/9781805120285.

Conventions used

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

Code In Text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. For example: “Manager.cs stores our score and loads the next scene.”

A block of code is set as follows:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Item: MonoBehaviour
{
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Player"){
            // 1
            Manager.Instance.score++;
            Destroy(this.gameObject);
            Debug.Log("Item collected!");
        }
    }
}

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

public class Item: MonoBehaviour
{
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            // 1
            GenericManager.Instance.score++;
            Destroy(this.gameObject);
            Debug.Log("Item collected!");
        }
    }
}

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: “Navigate to Assets | Scenes, and double-click on SplashScreen.”

Warnings or important notes appear like this.

Tips and tricks appear like this.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime