+ 3
Observer pattern and delegates
Please, someone, guide with a daily life example of how many attributes observer pattern has as I think 1. I need a subscriber which is simple contains methods. 2. Observer: In which I will subscribe method. 3. Provider: This is unknown to me but it is in ms documentation. Moreover, I wanted to reduce the dependency of my game scripts but I am not sure how to start working with this pattern. Start from basic and just give push than I will work on finding the complex usability. Thanks in advance 😊
6 ответов
+ 2
This recent course by Unity might be exactly what you're looking for:
https://learn.unity.com/project/c-scripting-in-unity-the-observer-pattern
Although I haven't personally reviewed it yet, the summary does seem to cover what you're looking for.
Since it is a recent course, I would hope it mentions the new Entity Components System (ECS) and DOTS architecture.
You may want to take a look at this as well:
https://www.habrador.com/tutorials/programming-patterns/3-observer-pattern/
These references will do a better job than what anyone can try to explain in a short answer post.
Hope this helps.
+ 2
Observe able and observers are introduced in the observer pattern in which we use subscription and in subscription to reduce the dependency.
For example
In my case, I use it as a simple delegate that subscribes to the methods at the game start, by which I am easy to handle dependency. Of game states. I am still reading so, please don't mind if I was wrong. Good luck 👍
+ 1
Also mention if it can be a mess in expanding my project as I am already with refactoring again and again 😩
+ 1
Thanks to all of your answers, I think I got 70 % of this question and the remaining will get from practice. Thanks, David Sir!