Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UniPool

Simple Object Pool Library for Unity

ObjectPools

1. ObjectPool<T>

最基础的Pool,可以通过:

  • Request - 获取对象,如果Pool为空,则抛出PoolException
  • Release - 放回对象

2. AutoAllocatePool<T>

ObjectPool的基础上,拥有自动创建对象功能, T满足new()约束。 在作Request请求时,若Pool为空,则自动new T();

3. ComponentPool<T>

1 . 基本特性

  • 这个类型的Pool专门用来存储UnityEngine.Component类型的对象。

  • 每个ComponentPool在场景中都有一个与之绑定的gameObject对象. 且该gameObject默认为active=false

  • 所有释放回Pool中的对象,都会成为Pool的gameObject的子节点

2 . Global模式

ComponentPool的构造函数中有global变量, 默认为true,即会gameObject标记为DontDestroyOnLoad,不会随场景销毁而销毁。

4. ResourcesComponentPool<T>

ComponentPool基础上,拥有了从Resources目录下自动加载Prefab的功能.

构造函数

ResourcesComponentPool(string name,string path)

path 指定了prefab要加载的路径

Collections Pools

1. ListPool<T>

可获取List<T>对象

2. SetPool<T>

可获取HashSet<T>对象

3. DictPool<K,V>

可获取Dictionary<K,V>对象

About

Simple Object Pool Library for Unity

Resources

Stars

8 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages