Member-only story
Unity: The Facade Pattern
Design Patterns With a Game Development Flair
The facade design pattern is used for hiding complexity behind simple interfaces. This article will demonstrate how to implement this pattern with a practical example. We will also see how we can use the pattern to decouple subsystems allowing for better, more maintainable code.
The entire project and its source code can be found on GitHub.
What Is the Facade Pattern
As mentioned above, the facade pattern is a design pattern that allows you to take complex behavior and hide it behind an easy to use interface. In this context, “interface” refers to a general point of connection, rather than a specific interface type in programming.
So let’s think of this in different terms. A house is an example of a facade. The house is an easy to understand interface but behind it is an interconnection of pipes, wires, and beams to make the house functional. So instead of referring to a house as each individual component we wrap all that in the idea of a house.
In GameDev Terms
So let’s put this in game development terms. If there were multiple panels in a game and we wanted to switch between them we could put all that logic in a single outside class, or we…