Use OnEnable to Setup Events and Statics.

Поділитися
Вставка
  • Опубліковано 26 сер 2024
  • Start and Awake don't get called on recompile and continue and Runtime InitializeOnLoadMethod does not get called with No Domain Reloading.
    These two combined can dramatically improve your development time, as it goes from seconds to load and get back to testing to get back to coding to Instant. Code while you run the game, support event driven behaviours.
    Please join Patreon / danvioletsagmiller
    Discord Link: / discord
    #unity #unity3d #tutorial #videogamedev #gamedev #architecture

КОМЕНТАРІ • 4

  • @vietdungdev
    @vietdungdev Рік тому +2

    wow, thanks for this trick, my unity run so fast now.

  • @tobario
    @tobario Рік тому +1

    Awesome Video, thank you. I just use Scriptable Object Events or Inspector Wired Unity Events for almost everything. It works like a charm.

  • @libberator5891
    @libberator5891 Рік тому

    I was about to write a long comment that's basically like "it works fine for me", but I had missed your point at 4:00 where you specify about having "Recompile and Continue Playing". You should put more emphasis on that point (felt glossed over or I just have poor attention). That's not a mode I usually use; I prefer "Recompile After Finished Playing". Properly unsubbing in OnDisable seems to also be called when it's playmode-recompiled, so that's good news.
    Side note: I like to use that [RunTimeInitializeOnLoadMethod] attribute for where the static things (events, collections, etc.) reside to reset them instead of each subscriber trying to do that. But, as you said, doesn't apply if you have the recompiling set to "Continue Playing"

    • @dvsdev
      @dvsdev  Рік тому

      I completely agree. I'm thinking I need to redo this video. When I put it together, the specific challenge I was addressing, was why do some events go away after a recompile and continue play or get damaged between plays with No Domain Reloading turned off. Specifically with both of them enabled at the same time, since they influence each other. Unfortunately, there is no great title to condense that. This feels more like a fragment of a college course.
      I'm considering creating a replacement video. But I don't have a better representation in mind yet. I'm all for ideas to simplify or redirect. I'm actually putting mind towards creating a series that show interconnecting patterns and principles within Unity. I.e. Once you have chosen feature X, you lose Feature Y and this other pattern changes because you lose Z.