Giter VIP home page Giter VIP logo

objectpoolmanager's Introduction

Object Pool Manager

Unity 2019.1+ License: MIT "Buy Me A Coffee"

Object pooling is a software design pattern used in computer programming to manage the reuse of objects. Instead of creating and destroying objects frequently, which can be resource-intensive and impact performance, object pooling maintains a pool of pre-initialized objects. When an object is needed, it is retrieved from the pool. After its use, instead of being destroyed, the object is returned to the pool for potential reuse later.

Why should you use this Object Pool Manager?

Because it is easy to use manager. It allows you to spawn objects using the same methods as instantiate without having to change your habits.

Installation

First of all, this asset dependent with Zenject. If you dont want to use Zenject, you can convert it with editing some codes related with Zenject.

https://github.com/modesttree/Zenject

or if you want Asset store

https://assetstore.unity.com/packages/tools/utilities/extenject-dependency-injection-ioc-157735

then;

  1. You can add git url via Package Manager => Add package from git url
https://github.com/supremepanda/ObjectPoolManager.git#upm
  1. You can also install via git url by adding this entry in your manifest.json
"com.supremepanda.object_pool_manager": "https://github.com/supremepanda/ObjectPoolManager.git#upm"

How to use?

  1. You should add ObjectPoolManagerInstaller to your prefered context (Scene or Project Context)
  2. You can inject ObjectPoolManager like this; [Inject] private ObjectPoolManager _objectPoolManager;
  3. You should inherit from PoolableComponent class for your pool objects.
  4. Then you can spawn or despawn objects using this manager. var target = _objectPoolManager.Spawn(_prefab, Vector3.zero, Quaternion.identity); _objectPoolManager.Despawn(target);

There are other method overrides on ObjectPoolManager abstract class if you want to check.

Important notes

  • If you install ObjectPoolManager with Project Context, probably you need to reset manager caches. There is a boolean checkbox on ObjectPoolManagerInstaller as ResetOnSceneChange, you can check if you want to reset when scene changed. Or you can call ResetPoolManager method manually.
  • If you are gettings exception related with Zenject, you can check your ZenAutoInjecter component on your PoolableComponent Gameobject. It should be set to SceneContext

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.