Skip to content

Instantly share code, notes, and snippets.

View bernardopacheco's full-sized avatar
:octocat:

Bernardo Pacheco bernardopacheco

:octocat:
View GitHub Profile
@bernardopacheco
bernardopacheco / 00_README.md
Last active May 8, 2024 03:17
Unity Event Manager event-driven architecture.

Unity Event Manager

This Gist represents an event-driven architecture that helps to structure my games in Unity. It uses events to trigger and communicate between decoupled parts of a game.

Usage

In the first game scene, create an empty Game Object named EventManager and attach the EventManager.cs script to it. This script is set to DontDestroyOnLoad, i.e., it won't be destroyed when reloading scene.

The Producer.cs and Consumer.cs classes show how an event is published and consumed. In this example, when a coin is collected, an addCoins event is published with the collected amount. A Consumer receives the amount of coins collected and update its own coins amount.