My Account Log in

1 option

Learning Design Patterns with Unity : Craft Reusable Code with Popular Software Design Patterns and Best Practices in Unity and C#.

O'Reilly Online Learning: Academic/Public Library Edition Available online

View online
Format:
Book
Author/Creator:
Ferrone, Harrison.
Series:
Expert insight.
Expert insight
Language:
English
Subjects (All):
Unity (Electronic resource).
Video games--Programming.
Video games.
C# (Computer program language).
Physical Description:
1 online resource (677 pages)
Edition:
1st ed.
Place of Publication:
Birmingham : Packt Publishing, Limited, 2024.
Summary:
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 that will take your game development skills to the next level. With structured explanations backed with practical examples, 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 book, the way you develop Unity games will change – you’ll adapt a more structured, scalable, and optimized process that will help you make that next leap in your career.
Contents:
Cover
Copyright
Contributors
Table of Contents
Preface
Chapter 1: Priming the System
A word about software architecture
What are Design Patterns?
The Gang of Four
Pattern categories
Creational patterns
Behavioral patterns
Structural patterns
Why use Design Patterns?
When to use Design Patterns
Common pitfalls
About the example projects
Client code
Old vs new input system
Art assets
Summary
Further reading
Chapter 2: Managing Access with the Singleton Pattern
Technical requirements
Breaking down the pattern
UML diagramming
Pros and cons
Updating a MonoBehavior into a persistent Singleton
Persisting the Singleton between scenes
Testing for duplicate managers
Creating a generic Singleton
Adding thread safety to the generic Singleton
Thread locking during lazy instantiation
Creating Singletons as ScriptableObjects
Chapter 3: Spawning Enemies with the Prototype Pattern
Breaking down the Prototype pattern
Diagraming the pattern
Implementing shallow and deep object copying
Adding a prototype interface
Making shallow object copies
Making deep object copies
Adding a prototype factory
Cloning prefabs
Creating a generic prototype Component
Chapter 4: Creating Items with the Factory Method Pattern
Breaking down the Factory Method pattern
Diagramming the pattern
Declaring our inventory products
Adding a product interface
Creating concrete products
Working with different factory class variations
Adding an abstract factory class
Building a concrete factory
Creating a concrete factory class
Building a parameterized factory.
Creating a parameterized factory class
Scaling factories with reflection and LINQ
Adding GameObjects to the mix
Updating the Item class
Updating the Abstract Creator class
Updating the concrete factory
Updating the reflection factory
Extending products and factories with Scriptable Objects
Chapter 5: Building a Crafting System with the Abstract Factory Pattern
Breaking down the Abstract Factory pattern
Creating related but independent products
Scripting product interfaces
Adding concrete products
Creating abstract and Concrete Factory classes
Writing a client class using only interfaces
Creating related and dependent products
Writing dependent product abstract classes
Adding abstract and Concrete Factory classes
Updating the client
Optional factory variations
Parameterized factories
Creating a factory of factories
Chapter 6: Assembling Support Characters with the Builder Pattern
Breaking down the Builder pattern
Creating a base ally and builder interface
Scripting the product class
Declaring a common builder interface
Adding concrete builders
Using a director class
Integrating GameObjects
Transitioning to a Fluent Builder structure
Chapter 7: Managing Performance and Memory with Object Pooling
Breaking down the Object Pool pattern
Writing an Object Pool class
Creating objects and filling the pool
Retrieving pooled objects
Releasing pooled objects
Resetting pooled objects
Object Pooling customizations.
Queues over lists
Thread-safe pools
Managing different pooled objects
Leveraging Unity's ObjectPool class
Chapter 8: Binding Actions with the Command Pattern
Breaking down the Command pattern
Reusable versus single-use commands
Building a basic Command structure
Creating reusable commands
Adding a receiver
Adding an invoker class
Using an input listener
Creating coupled commands
Implementing an undo/redo system
Stacking commands
Adding an undo feature
Adding a redo feature
Confirming and clearing commands
Chapter 9: Decoupling Systems with the Observer Pattern
Breaking down the Observer pattern
Creating a basic Observer structure
Writing the abstract base objects
Making the UI an observer
Subscribing observers and publishing events
Pattern strategies and optimizations
Choosing a communication strategy
Listening for different state changes
Cleaning up hanging resources
Using C# event types
Delegates and events
Updating to Action types
UnityEvents and the Inspector
Adding Unity events
Adding UnityEvent parameters
Persistent versus non-persistent events
The final boss - drag-and-drop system
Writing a ScriptableObject event
Creating listeners
Creating ScriptableObject event assets
Invoking the SOEvent
Connecting the system
Performance considerations
Picking the right implementation
Chapter 10: Controlling Behavior with the State Pattern
Breaking down the State pattern
A little automata theory
Pros and cons.
Creating a turn-based battle system
Defining abstract and base states
Creating a state machine
Protecting transitioning states
Subclassing state machines
Creating concrete states
Base state
Setup state
Player state
Enemy state
Ending state
Putting it all together
Initializing concrete states
Using a hierarchical state machine
Adapting for concurrent state machines
Unrelated concurrent states
Related concurrent states
Storing state history
Pushing new states
Reverting to previous states
Chapter 11: Adding Features with the Visitor Pattern
Breaking down the Visitor pattern
Creating a save system
Structuring the interfaces
Adding a concrete Visitors
Adding concrete elements
Adding an object structure
Working with composite elements
Accounting for selective visitation
Chapter 12: Swapping Algorithms with the Strategy Pattern
Breaking down the Strategy pattern
Creating a sorting system
Defining a strategy interface
Adding concrete strategies
Creating a context
Optimizing your strategies
Adding interchangeable strategies
Using default strategies
Strategies the Unity way
Upgrading to ScriptableObjects
Chapter 13: Making Monsters with the Type Object Pattern
Breaking down the Type Object pattern
Creating monsters
Adding a Type Object
Configuring monsters
Optimization, inheritance, and behavior
Controlling allocation and initialization
Adding parent type objects
Sharing behavior isn't easy.
Creating ScriptableObject monsters
Chapter 14: Taking Data Snapshots with the Memento Pattern
Breaking down the Memento pattern
Creating and restoring data snapshots
Adding the memento class
Setting up the caretaker
Updating the originator
Wiring up the client
Working with MonoBehaviours
Memento pattern variations
Storing memento history
Bundling originator and caretaker
Managers and ScriptableObject snapshots
Persisting data
Chapter 15: Dynamic Upgrades with the Decorator Pattern
Breaking down the Decorator pattern
Building a simple Decorator
Adding a Component interface
Creating a concrete Component
Using a base Decorator
Building a concrete Decorator
Chaining multiple Decorators
Adding customized behaviors
Using ScriptableObject Decorators
Static vs dynamic decoration in action
Chapter 16: Converting Incompatible Classes with the Adapter Pattern
Breaking down the Adapter pattern
Building a controller adapter
Defining a target
Adding the class adapter
Creating an object adapter class
Mapping properties in separate hierarchies
Chapter 17: Simplifying Subsystems with the Façade Pattern
Breaking down the Façade pattern
Building a subsystem Façade
Defining subsystem objects
Initializing subsystems
Adding a public Façade method
Adding multiple Façade methods
Upgrading Façades
Further reading.
Chapter 18: Generating Terrains with the Flyweight Pattern.
Notes:
Description based upon print version of record.
Technical requirements
Description based on publisher supplied metadata and other sources.
Other Format:
Print version: Ferrone, Harrison Learning Design Patterns with Unity
ISBN:
9781805124160
OCLC:
1436832558

The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.

My Account

Shelf Request an item Bookmarks Fines and fees Settings

Guides

Using the Library Catalog Using Articles+ Library Account