Design principles, design patterns, coding challenges, and more!
Details
Here is a complete overview of Best Practices and related topics for Unity.
The repo is complete with code samples.
Enjoy!
Related Repos
Name | Description | Educational Use | Production Use | Link |
---|---|---|---|---|
Unity Best Practices | Repo with best practices for Unity. It covers project structure and code standards. | ✅ | ❌ | (See below) |
Unity Project Template | Template showcasing best practices and coding standards for Unity projects. | ❌ | ✅ | link |
- Download this repo (*.zip or *.git)
- Download the Unity Editor (See
Unity Version
below) - Open the Unity Hub
- Unity Hub: Click the 'Add' button
- Unity Hub: Choose the
Unity
folder from the repo - Unity Hub: Choose the project from the project list to open the Unity Editor
- Unity Editor: Open one of the included Scenes
- Unity Editor: Play the Scene
- Enjoy!
Documentation
ReadMe.md
- The primary documentation for this repo
Configuration
Unity Target
- Standalone MAC/PCUnity Version
- Use this VersionUnity Rendering
- Universal Render Pipeline (URP)Unity Aspect Ratio
- Game View 10x16
Structure
Unity
- Open this folder in the Unity Editor
Dependencies
Various
- Already included via Unity Package Manager as this Version
Theory
S.O.L.I.D. Principles make software designs more understandable, easier to maintain and easier to extend. As a software engineer, these 5 principles are essential to know! (See ITNext.io)
List
Name | Description | Code Sample Complete |
---|---|---|
Single Responsibility | One reason to change. | ✅ |
Open/Closed | Open for extension, closed for modification. | ✅ |
Liskov Substitution | Subtypes must be substitutable for their base types. | ✅ |
Interface Segregation | No client should be forced to depend on interfaces they do not use. | ✅ |
Dependency Inversion | High-level modules should not depend on low-level ones; both should depend on abstractions. | ✅ |
These patterns provide solutions to common design problems and are a foundational part of software design knowledge. There are 3 types.
- Behavioral Patterns - Design patterns to deal with object-object communication. (See Wikipedia)
- Creational Patterns - Design patterns to deal with object creation. (See Wikipedia)
- Structural Patterns - Design patterns to deal with object-object relationships. (See Wikipedia)
Type | Name | Description | Code Sample Complete |
---|---|---|---|
Behavioral | |||
Chain of Responsibility | Passes request among a chain of objects. | ❌ | |
Command | Encapsulates a request as an object. | ✅ | |
Interpreter | Provides a language interpreter. | ❌ | |
Iterator | Sequentially access elements in a collection. | ❌ | |
Mediator | Centralized external communications. | ❌ | |
Memento | Capture and restore object's internal state. | ✅ | |
Observer | Notify changes to its state. | ❌ | |
State | Alter behavior when its state changes. | ✅ | |
Strategy | Encapsulates algorithms using strategy pattern. | ✅ | |
Template Method | Defer exact steps to subclasses. | ❌ | |
Visitor | Add new operations without altering a class. | ❌ | |
Creational | |||
Abstract Factory | Creates families of related objects. | ❌ | |
Builder | Separates object construction from its representation. | ✅ | |
Factory Method | Creates objects without specifying the exact class to create. | ✅ | |
Prototype | Clone or copy initialized instances. | ❌ | |
Singleton | Ensures a class has one instance. | ✅ | |
Structural | |||
Adapter | Matches interfaces of different classes. | ❌ | |
Bridge | Separates an object’s interface from its implementation. | ❌ | |
Composite | Tree structure of simple and composite objects. | ❌ | |
Decorator | Adds responsibilities to objects dynamically. | ✅ | |
Facade | Simplified interface to a subsystem. | ✅ | |
Flyweight | Reuses objects by sharing common state. | ✅ | |
Proxy | Represents another object. | ❌ |
- Editor Scripting - Unity lets you extend the editor with your own custom inspectors and Editor Windows and you can define how properties are displayed in the inspector with custom Property Drawers. See Unity Docs for more.
- Unit Testing - Software testing where individual units/ components of a software are tested. The purpose is to validate that each unit of the software performs as designed. A unit is the smallest testable part of any software. See Unity Docs for more.
Created By
- Samuel Asher Rivello
- Over 25 years XP with game development (2024)
- Over 11 years XP with Unity (2024)
Contact
- Twitter - @srivello
- Git - Github.com/SamuelAsherRivello
- Resume & Portfolio - SamuelAsherRivello.com
- LinkedIn - Linkedin.com/in/SamuelAsherRivello <--- Say Hello! :)
License
Provided as-is under MIT License | Copyright ™ & © 2006 - 2024 Rivello Multimedia Consulting, LLC