Observer Pattern In Unity

Code can be find in the Design Patterns GitHub Repo:
github.com/metalac190/UnityDe...
00:00 - Concept
05:16 - Damage Example

Пікірлер: 22

  • @haruxe5140
    @haruxe51403 жыл бұрын

    Events were oddly hard to wrap my head around and this video cleared up some of the confusion I had with them, thanks!

  • @HAMSTERKILLER666
    @HAMSTERKILLER666 Жыл бұрын

    These videos are amazing. Thank you

  • @robertbrozewicz8003
    @robertbrozewicz80038 ай бұрын

    Finally I started to understand the actually extremely tricky because it is very instinctive and simple but at the same time hard because it is multidimensional. One dimension is the event that happens on the subject. The other subdimension is the triggering the event by the subject (although it is triggered by something-- event ) .. Then we get out of this and realize that other objects (now subjects hence the idea of other dimensions ) observe and then react to the triggered event that was although triggered on foreign subject but was notified.. Then can act according to own logic .. Both logics are totally independent on each other so the dimensions are connected but live independently. It is like human body. It responds to stimuli but the way internal organs work is not related directly to the environment. It allows for complex systems that can be interacting with one another.. It basically exists everywhere..

  • @fernandopessoa5304
    @fernandopessoa5304Ай бұрын

    Muito bom !!! você é incrível

  • @Palerider1011
    @Palerider10113 жыл бұрын

    I've been watching tutorials on C# and Unity Events, you have broken it down the best I've seen. Thanks! Great job

  • @AmazinglyStrangeMedia
    @AmazinglyStrangeMedia Жыл бұрын

    Your video are EXCELLENT for the right brain folks. However you are explaining it, I am getting it. The simple picture images at the beginning a so helpful for the visual learner. Best wishes and keep up the great work!

  • @BazSupport
    @BazSupport3 жыл бұрын

    You broke this down so well, ive been at trying to understand these for almost a year now.... the visual was so much better then starting right off in code like others do

  • @shozzru3074
    @shozzru30743 жыл бұрын

    Thank you so much for all your videos; you explain things really well and have taught me quite a bit ^_^

  • @Eduard02834
    @Eduard028342 жыл бұрын

    Very good explanation

  • @hernandonj
    @hernandonj2 жыл бұрын

    Awesome video, very well explained, and examples are great! it's just 7 min and thing are clearer to me. Thank you!

  • @michaelberna987
    @michaelberna9872 жыл бұрын

    We are not creating this weird spaghetti code. ME: "proceeds to casually hide my visual studio project"

  • @dougwarner59
    @dougwarner592 жыл бұрын

    I think you should add that the broadcaster (subject) invokes an event without needing to worry about which observers will receive it and how they will handle their code. And, because of the restrictions placed on the event, all observers cannot interacting with each other. This makes it easy to add and remove observers(functionality) without having to change a lot of code; and when errors do occur it would allow you to isolate the code to specific regions, because the subjects and all of the observers are for the most part isolated from each other. Note: I see You have the following in the explanation: Damage.Invoke(amount); you could have just put Damage(amount); it looks like you might be using an anonymous method with a default empty handler to avoid the null check(at least that what it looks like you are doing); if not you will need to use a null conditional(Elvis) operator such as: Damaged?.Invoke(amount); to avoid a null reference exception just in case no observers are assigned.

  • @walkwithsharif3341
    @walkwithsharif33413 жыл бұрын

    Awesome explanation or Excellent

  • @DieDona
    @DieDona2 жыл бұрын

    Great tutorial!

  • @smirelesz
    @smirelesz Жыл бұрын

    Thank you for this video. Easy to follow up and to implement. I like how you began explaining the concept before diving into the project. Gracias!

  • @sekker2k446
    @sekker2k4463 жыл бұрын

    Cool😉

  • @mangopudding7245
    @mangopudding72452 жыл бұрын

    doggo bark at 8:52

  • @diato2993
    @diato29933 жыл бұрын

    what should I do if I want to use the same Sound play, or UI pop up for another Object for instance, looting coins should I code it at on enable ex) health.event+=soundplay coins.event+=soundplay like that?

  • @missquprison

    @missquprison

    2 жыл бұрын

    Yeah you just "subscribe" soundplay function to 2 separate events.

  • @vandermunnik
    @vandermunnik2 жыл бұрын

    Is it necessary to include " = delegate { };" ? When I don't use it it still works, like "public event Action Killed; "

  • @acdev7027

    @acdev7027

    2 жыл бұрын

    It saves you from having to do a null check when you call it (Action?.Invoke() ) but its optional. If its empty and its called jt just wont error out

  • @IDontReadReplies42069
    @IDontReadReplies420692 жыл бұрын

    Not as much of a pattern is it is just...using events lol