Programming Study Group - / discord
My IT music channel - https://youtube.com/@RDMusic76-t9u?si...
My gaming channel - / @rdgames-j7s
Design Patterns: Observer in Unity and C#
In this video, we explore one of the most popular behavioral design patterns—Observer. You'll learn how to eliminate rigid dependencies between classes and make your project architecture more flexible and extensible.
In this episode:
Real-Life Analogy: How a Newspaper Subscription Works and Why It's a Perfect Example of Observer [00:09].
The "God Class" Problem: A Bad Example of Item Lifting in a Game, When a Single Class Knows About All Services (Sound, UI, Quests, Effects) [01:11].
C# Implementation: Why the Standard Event and Delegate Are the Observer Pattern Out of the Box [03:20].
Classic Pattern: ISubject and IObserver Interfaces, Attach, Detach, and Notify Methods [04:09].
Modern Approaches in Unity:
Using Static Events (and Their Drawbacks) [05:41].
Implementation via Scriptable Objects (Event Channels) – Pros and Cons [10:55].
Dependency Injection via DI Containers (VContainer/Zenject) for Subscription Management [12:37]. What's up with UniRx? Why classic UniRx is considered obsolete and what's worth paying attention to today (R3 library) [09:59].
The main advantages of the pattern:
Low Coupling: Objects don't directly know about each other.
Single Responsibility: Each class is responsible only for its own logic.
Scalability: It's easy to add new listeners without changing the sender code.
Sur cette page du site, vous pouvez voir la vidéo en ligne Patterns - Observer (Unity) - 14 durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur RDragon 28 novembre 2025, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 251 fois et il a aimé 18 téléspectateurs. Bon visionnage!