Delegates, Events, Actions and Funcs - The Observer Pattern (Unity & C#)
Video Statistics and Information
Channel: One Wheel Studio
Views: 17,475
Rating: undefined out of 5
Keywords: Unity3d, Indie Game, Programming Patterns, Observer Pattern, Delegates, Events, Actions
Id: UWMmib1RYFE
Channel Id: undefined
Length: 11min 48sec (708 seconds)
Published: Thu Aug 06 2020
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
The next video in a series of programming pattern videos! I'm making these mostly to firm up my own knowledge and understandings of these patterns. They have certainly been covered before, but hopefully, they are still helpful to someone.
Great video, I'm always interested in seeing how others are implementing their games.
I use events in my project along with the
EventHandler
orEventHandler<TEventArgs>
delegates. This allows me to always know what object fired the event in case I need to use it downstream. It's just slightly different than the code you presented.For defining the event:
With the AdventurerAssignedEventArgs class as:
And of course registering is the same as what you presented.
I fucking needed this. Saved for later. Canβt wait to get off vacation
Is using event manager approach considered the same as observer pattern? I notice some like to use that style where other object start/stop listening using static method and usually string event name.
What are the pro con using the event manager approach compared to using events directly?