Giter VIP home page Giter VIP logo

unity-pooltool's Introduction

HAIPoolTool

A general object pool plugin for personal development for your Unity project

How to use it for your project?

You just need to clone it to any folder of yours and choose to import it in the Import Package in the unity panel.
You need to create an empty object named PoolManager in your project, it will act as your object pool manager, after that you should add the script "PoolManager" to it, you can find it in the getcomponent panel, or in in your scripts folder.

Its function

This is a general object pool plugin that allows you to generate object pools for multiple items through configuration or code for unified management.

Initialize the object pool

You can initialize your object pool by drag and drop in unity's hierarchy panel, like this image
Of course, you can also create object pools in code. Just call the method

PoolManager.Instance.AddToPool(string tag,GameObject poolItemObj,int Count)

Take and Recycle

You can take a single game object by the pool name, or you can take any number of objects by yourself, and call the following method:

PoolManager.Instance.GetPoolObject(string tag)
PoolManager.Instance.GetPoolObjects(string tag,int count)

Likewise, we support you to recycle a single game object or multiple:

PoolManager.Instance.RecycleObjectToPool(string tag,GameObject poolObj)
PoolManager.Instance.RecycleObjectsToPool(string tag)

Automatic expansion

You don't need to worry about its usage. When the pool exists and is exhausted, it will adopt an exponential growth strategy of 2 to expand one of your object pools.

Clearing the object pool

You can choose to destroy a single object pool by character index, or you can call a method to destroy all object pools:

PoolManager.Instance.ClearAnyPool(string tag)
PoolManager.Instance.ClearAllPool()

Advantages and disadvantages

It can be very convenient for you to create object pools for any object in the form of different names, and manage nodes at the same time, and the efficiency of taking and recycling is very good. Of course, I am not providing more interfaces to facilitate your other ideas and operations. I choose to leave it to you to implement more details. In addition, you can also use direct inheritance to customize the object pool that better suits your needs, which I believe would be a great thing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.