Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
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 Learn the secret of popular design patterns while building fun, efficient games in Unity 2023 and C#

Arrow left icon
Product type Paperback
Published in May 2024
Publisher Packt
ISBN-13 9781805120285
Length 676 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Harrison Ferrone Harrison Ferrone
Author Profile Icon Harrison Ferrone
Harrison Ferrone
Arrow right icon
View More author details
Toc

Table of Contents (23) Chapters Close

Preface 1. Priming the System FREE CHAPTER 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

About the example projects

When I first started learning about design patterns, I found the wealth of resources, tutorials, and applicable scenarios overwhelming (if this has happened to you too, I hope finding this book will make your journey much, much easier). The problem wasn’t the technical information that I was finding, but the way it was presented. More often than not, the design pattern content seemed to be shrouded in dry, overbearing technical language, complicated examples, or just plain old incorrect solutions.

One of my main goals in writing this book was to present the foundation of these wonderful tools with as little fluff as possible. However, this turns problematic when trying to find a balance between teaching the design pattern itself and getting it to run in a meaningful way – because just like design patterns, new skills wither and die in a vacuum. This is all to say that I’ve created the starter projects for each chapter as simply and meaningfully as I possibly can. The balance is delicate, and you might find the examples weighted to one side or the other, but it’s always been with the intention of making the design pattern the star.

Client code

Some of the ways I’ve implemented UI code, client scripts, or any of the simple systems around using each design pattern are not production-ready or best practices – they are the simplest way of using the pattern with context. On the flip side, I’ve given as much thought and page count as possible to pattern variations, extensions, and best practices so you have concrete tools to bring to your own projects.

Again, this book isn’t about Unity (although it’s a delightfully fun learning environment), but rather how we can learn problem solving skills and apply them to software.

Old vs new input system

As you’ll see in the next chapter and onwards, I’m using Unity’s old Input System rather than the new Input System. Why? Because it’s the simplest way to get the client code running with a minimum amount of setup and screenshots for you to follow. I love the new input system (I feel I need to put this on the record or risk banishment), but it does require a little specialized knowledge and experience that doesn’t contribute to design patterns. As always, I encourage you to experiment with implementing the design pattern solutions in whatever context works best for your project. For learning, I’ve found the old Input System works best.

Art assets

I love beautiful Unity projects that are full of life, sound, ambiance, and thematic feeling, but these things don’t help us learn new skills – in fact, they tend to distract at best and hinder at worst. All example projects use the most basic primitive objects and materials possible (essentially white boxing everything), not only to keep things consistent but to keep you focused on the design patterns. And who knows, the lack of excitement in our projects might just inspire you to deploy your new skills in ways you hadn’t thought of before.

I hope the simplicity of the examples I’ve prepared doesn’t make you nervous, because it should really make you hopeful. The fact that we can use these patterns as systems to be plugged in and interchanged with the UI, clients, or any other aspect of application development only strengthens the very first point of this chapter – design patterns are systems!

You have been reading a chapter from
Learning Design Patterns with Unity
Published in: May 2024
Publisher: Packt
ISBN-13: 9781805120285
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 $19.99/month. Cancel anytime
Banner background image