Delegates? Basically, UnityEvents. But Cooler | Unity C# Basics Part 5

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ต.ค. 2024

ความคิดเห็น • 8

  • @chrisb9042
    @chrisb9042 ปีที่แล้ว +1

    you're the best, always so helpful w/ the most particular thing i need help with.

  • @juice1884
    @juice1884 2 ปีที่แล้ว +1

    Completely missed the event keyword of C#, a fundamental aspect of working with delegates as events.

    • @LlamAcademy
      @LlamAcademy  2 ปีที่แล้ว

      Thanks for the reply!
      Events were intentionally not included in this video to avoid muddying the waters between delegates and events. Many beginners (and more advanced developers even!) are confused on when they should use events versus a delegate.
      Microsoft themselves acknowledge this can cause confusion: docs.microsoft.com/en-us/dotnet/csharp/distinguish-delegates-events

  • @dibaterman
    @dibaterman 2 ปีที่แล้ว

    Yeah, a couple of things throw me off on what is happening here, I had to rewatch the video in pieces to get it. For people as slow as I am about this stuff here's what I gather is missing.
    To summarize a delegate is a way of informing other scripts that it is not null.
    On object pooling... this part should have just not been in the video, I think this is what kept my OCD flaring. I've been working on animations for maybe 3 hours now so the words are not sounding like a language anymore after rewatching this so much. Good luck folks!

    • @LlamAcademy
      @LlamAcademy  2 ปีที่แล้ว +1

      Yeah, I was struggling with how to not include the object pooling section but still showcase the dangers of not removing handlers and how to remove them.
      I would rephrase your summary to: delegates are a way to inform other scripts of when specific things happen in this script, in a structured manner.

    • @dibaterman
      @dibaterman 2 ปีที่แล้ว +1

      @@LlamAcademy Yeah, I fortunately had a friend I asked about this, he said the use case for delegates is for UI. This made my OCD finally die down. Been getting a headache >.

    • @dibaterman
      @dibaterman 2 ปีที่แล้ว +2

      @@LlamAcademy So I went to the Unity Learn site to try their exercise on it, I get it now sort of, still learning. But it's basically like a folder that can hold multiple functions so long as they share the identical arguments. I can assign functions to it with += or = operators and when I call it-it just unloads everything in the folder.

    • @terryterry8744
      @terryterry8744 ปีที่แล้ว

      @@dibaterman this is a really good description, I finally understand