← All patterns
Structural

Facade

Give a tangle of subsystems one simple front door so the rest of the game only makes one call.

What Is It?

A Facade is a single class that offers a small, task-oriented API on top of several lower-level systems. It does not hide those systems from everyone; it just means ordinary callers no longer need to know how they fit together.

Think about what a convincing explosion needs: grab a free AudioSource from a pool, route it through the SFX group of an AudioMixer, briefly duck the music, and rumble the controller. Without a facade, every grenade, barrel and rocket script repeats that choreography. With an AudioFacade, they all call PlayExplosion(position) and move on.

The subsystems stay fully usable on their own. The facade simply bundles the common recipes, so the knowledge of "how we do an explosion here" lives in exactly one place.

When Is It Used?

Use it when many clients repeat the same multi-step sequence across several systems: audio and feedback, saving and loading, scene transitions, analytics plus achievements plus cloud sync.

It is a good boundary around a third-party package or a large internal module, so most of the codebase only touches a few well-named methods.

Avoid letting it grow into a god object that every system routes through. If the facade starts accumulating unrelated responsibilities, split it into several focused facades.

Interactive Demo

Click the controls and watch the objects collaborate. The console mirrors what the C# code below would log.

Code

Assets / Scripts / Structural/ Facade ›Grenade.cs
using UnityEngine;

namespace Patterns.Structural.Facade
{
    /// <summary>
    /// Client. Knows nothing about pools, mixers or haptics: it asks the
    /// facade for an explosion and gets the whole package.
    /// </summary>
    public class Grenade : MonoBehaviour
    {
        [SerializeField] private AudioFacade audioFacade;
        [SerializeField] private float fuseSeconds = 2.5f;

        private float timer;

        private void OnEnable() => timer = fuseSeconds;

        private void Update()
        {
            timer -= Time.deltaTime;
            if (timer > 0f) return;

            audioFacade.PlayExplosion(transform.position);
            gameObject.SetActive(false);
        }
    }
}
3 files · namespace Patterns.Structural.FacadeC# · UTF-8 · LF

Advantages & Disadvantages

+ Advantages

  • Clients become simple and decoupled from the details of each subsystem.
  • Shared recipes are defined once, so tuning an explosion is a one-file change.
  • Subsystems can be refactored or swapped behind the facade without touching callers.

− Disadvantages

  • Can turn into a god class if every new feature gets bolted on.
  • Callers that need fine control still have to go around it, so you maintain two paths.
  • Often implemented as a global singleton, which brings its own testing and coupling issues.

Tips

  1. 01Name facade methods after game intents (PlayExplosion, EnterCombat), not after the subsystems they touch.
  2. 02Inject the subsystems into the facade via [SerializeField] references so they remain visible and swappable in the Inspector.
  3. 03Keep the facade thin: it should orchestrate, not reimplement. Real logic belongs in the subsystems.
  4. 04Pair it with a Service Locator or DI container rather than a static Instance if you want testable callers.
  5. 05Use AudioMixer.FindSnapshot and TransitionTo inside the facade for ducking instead of manually lerping volumes.