Over 11,000 five-star assets

Rated by 85,000+ customers

Supported by 100,000+ forum members

Every asset moderated by Unity

Home
Tools
Utilities
This content is hosted by a third party provider that does not allow video views without acceptance of Targeting Cookies. Please set your cookie preferences for Targeting Cookies to yes if you wish to view videos from these providers.
1/5

Pub\Sub Messenger is a Lightweight, Open Source Library for Unity.

This library will provide a Pub\Sub Mechanism that is a part of SOLID principles in programming.


PROBLEMS IN GAMES

* Wiring the Parts with Events – Tightly Coupled and may cause Memory Leak problems. The Publisher and the Subscriber have to know of each other, and a Subscriber can’t be collected by the GC if it’s connected with the Publisher with strong event reference.

* Using Unity Event Routing – Although Unity Event Routing is a very good feature, it is a Unity Specific Solution and we need a generic one. Also, we cannot use it everywhere even if the project is in Unity.

* Dependency - In commonly used C# events or delegates, classes are “familiar” with each other and this prevents good modularity. This is NOT following SOLID Principles and Objects are not Encapsulated.


THE SOLUTION

* Pub\Sub Messenger - Container for Events that allows Decoupling of Publishers and Subscribers so they can evolve independently. This Decoupling is useful in Modularised Applications because new modules can be added that respond to events defined by the Shell or, more likely, other modules. All events have a Weak Reference and invocation can be done Async or Sync way.

* Payloads - Instead of passing objects or modules, pass small Payloads (Data/Messages) that are relevant for the specific cases/events.

* Encapsulation - Classes/Modules will not be “familiar” with each other, this will allow better encapsulation and less dependencies.

* Weak Reference - In case of subscriber’s destruction, it will be removed automatically from Messenger’s list, since it was referenced via Weak Reference.

* SOLID Principles - Pub/Sub can be a great pattern in combination with Dependency Injection (DP) and with Inversion of Control (IoC), both part of SOLID Principles.


Supported Platforms: Android, iOS, Windows, Mac, Linux, WebGL

Supported Unity Versions: 2017.x, 2018.x, 2019.x


Sources

* GitHub Project

* Youtube Clip

Pub-Sub Messenger

(7)
43 users have favourite this asset
(43)
FREE
10 views in the past week
License type
File size
1.1 MB
Latest version
1.0.1
Latest release date
Aug 17, 2021
Original Unity version
2020.3.5
Support
Visit site
Quality assets
Over 11,000 five-star assets
Trusted
Rated by 85,000+ customers
Community support
Supported by 100,000+ forum members
Unity logo
Language
Feedback
Partners Program
Partners
USD
EUR
Copyright © 2025 Unity Technologies
All prices are exclusive of tax
USD
EUR