Object Pooling in Unity! Easy Tutorial!!

Sdílet
Vložit

Komentáře • 7

  • @adamodimattia
    @adamodimattia Před 29 dny +1

    By now, there is already Unity built-in object pooling api :)

  • @Tenetri
    @Tenetri Před 5 měsíci +1

    really cool explanation, very inspiring! Thank you!

  • @ryanwinchy
    @ryanwinchy Před 5 měsíci

    So useful thanks so much! Hadn't seen this before. So well explained.
    Would love to see more tutorials :)

    • @GarnetKane
      @GarnetKane  Před 4 měsíci

      Appreciate it! More tutorials coming :)

  • @tr25ny
    @tr25ny Před 2 měsíci

    For some reason when the pool is full and all of them are in use and then starts instantiating new objects, it then skips generating every 2nd object from then on.

  • @urpwnned
    @urpwnned Před 4 měsíci +2

    Im having a really hard time understanding how dictionaries work :(

    • @GarnetKane
      @GarnetKane  Před 3 měsíci +2

      Hey there! Apologies on the delay in my response - hopefully this explanation helps.
      A Dictionary is set up which includes 2 properties, a KEY and a VALUE - think of the KEY as almost like a username, and the value is the account that it belongs to. When you put the Key into the dictionary, if it contains an entry (as in the account exists somewhere), then it will return it.
      So setup would be like:
      Dictionary myDictionary = new Dictionary();
      in this case, our KEY is the string and our VALUE is the integer.
      Now think of a list setup, you would add to a dictionary similar to how you would a list, but this time you need the identifier (key) and you need the value. So initialising the dictionary would be something like:
      myDictionary.Add("Garnet", 100);
      so by doing this, we now have a unique entry for something called Garnet that has a value of 100.
      When we want to look through the dictionary to find a value, we can search by doing something like:
      myDictionary["Garnet"] -> but this is ASSUMING we know that there's a key for Garnet, a more common approach would to null check it
      if(myDictionary.ContainsKey("Garnet")){
      print(myDictionary["Garnet"]);
      }
      It's definitely a lot to wrap your head around, but I hope this helped in some way with it!