Book Image

Learning Design Patterns with Unity

By : Harrison Ferrone
Book Image

Learning Design Patterns with Unity

By: Harrison Ferrone

Overview of this book

Struggling to write maintainable and clean code for your Unity games? Look no further! Learning Design Patterns with Unity empowers you to harness the fullest potential of popular design patterns while building exciting Unity projects. Through hands-on game development, you'll master creational patterns like Prototype to efficiently spawn enemies and delve into behavioral patterns like Observer to create reactive game mechanics. As you progress, you'll also identify the negative impacts of bad architectural decisions and understand how to overcome them with simple but effective practices. By the end of this Unity 2023 book, the way you develop Unity games will change. You'll emerge not just as a more skilled Unity developer, but as a well-rounded software engineer equipped with industry-leading design patterns.
Table of Contents (23 chapters)
21
Other Books You May Enjoy
22
Index

The final boss – drag-and-drop system

Back at the 2017 Unite conference, there was a wonderful talk about building out your game architecture using scriptable objects. Unity has come a long way since then, but scriptable objects are still one of the most useful programming tools for encapsulating data in your games. In this last section, we’ll implement the drag-and-drop Observer pattern structure from the Unite conference to give you a starting point for more advanced Unity configurations.

You can find the Unite talk at https://www.youtube.com/watch?v=raQ3iHhE_Kk&t=0s&ab_channel=Unity and a brief write-up by Ryan Hipple at https://unity.com/how-to/architect-game-code-scriptable-objects.

Writing a ScriptableObject event

The strategy behind this implementation is to encapsulate a subject into a ScriptableObject, which should look familiar because it’s almost exactly what we did at the beginning of the chapter with our traditional...