Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more..
    Dismiss Notice
  3. Dismiss Notice

Can someone teach me more about how to use EZ object pools?

Discussion in 'Scripting' started by hulahop567, Dec 19, 2018.

  1. hulahop567

    hulahop567

    Joined:
    Nov 28, 2018
    Posts:
    3
    Hello, I am trying to modify my instantiate/destroy codes to object pool method, however being a complete noob at C# it's hard to understand the concept, I found this asset EZ object pools and looks like it can do the job. Can someone explain it to me further? (tried the documentation and failed) I have 6 different moving enemy cars, with speed and spawning rate gradually going up throughout the game. Also a pair of moving objects whose speed goes up throughout the game. Any help? I can post my codes if you need it. Will be glad if someone replies!
     
  2. mridulbhagat120

    mridulbhagat120

    Joined:
    Nov 8, 2018
    Posts:
    10
    seems like there`s no way outta it
     
  3. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,357
    THe documentation is pretty straight-forward. What part do you need explained?
     
    xVergilx likes this.
  4. hulahop567

    hulahop567

    Joined:
    Nov 28, 2018
    Posts:
    3
    How to implement it? It said to add codes on scripts..but which scripts exactly?? Also tried the gameobject method..but the same problem..sorry, if these are silly questions, but i am very new to all these!
     
  5. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,916
  6. hulahop567

    hulahop567

    Joined:
    Nov 28, 2018
    Posts:
    3
  7. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,916
    Then report it to Unity. Every Asset Store asset should have support by the rules, even free ones. They will take it down if the author does not care about his/her package.

    We don't use this package so we cannot help you. Well I don't use this asset so I can't help you.
    But there are great beginner-friendly tutorials how to pool objects.
    For example Brackey's, you can use Google or YouTube to find more.
     
  8. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,357
    It's just telling you to drag the EZObjectPool script on to an object. That's all it is. Just make an empty game object and put it on there, or else use whatever manager object that you're already instantiating things from.

    How to set up the pool us explained on the previous page. For "template", drag the prefab for the car that you want to spawn, and for "Pool Size" put a number of how many you want in the pool.

    If you set up your pool in the inspector, as per the instructions then all you'd really need from the API is probably the TryGetNextObject function. Use TryGetNextObject to get an object from the pool (i.e. where ever you use GameObject.Instantiate, use TryGetNextObject instead) and then deactivate the object to return it to the pool.

    That's pretty-much all you need to do.