Skip to content

Commit d2275fc

Browse files
authored
Update README.md
1 parent 8ba5eaf commit d2275fc

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

README.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
# Unity-Object-Pool
2-
A singleton object pooler for all of your optimization. It can handle all of the object pooling during the game loading and is persistant throughout scenes
3-
4-
Currently to get the objects from the pool you need to know the position in the pool, will be changed to either use the position or the name.
5-
2+
A very simple singleton object pooler for optimization. It can handle all of the object pooling during the game loading and is persistant throughout scenes
3+
4+
Currently to get the objects from the pool you need to know the index in the pool, will be changed to either use the position or the name.
5+
# What is pooling?
6+
It is computationally expensive to instantiate and destroy objects like bullets that get re-used a lot.
7+
Its a lot more effective to instantiate them all in the beginning and to keep re-using them by setting them active/false
8+
9+
This script can act as a pooling control hub, it will create all pooled objects you need at the start and objects can be called as and when needed by other scripts.
10+
11+
## How to setup
12+
1) Create a new empty GameObject
13+
2) Create a new script called ObjectPooler and attach it to the GameObject
14+
3) Replace the contents of ObjectPooler with contents of the ObjectPooler script that can be found in this repo.
15+
4) In the inspector, in the script component, enter the number of gameObjects you want pooled and then add their prefabs to the list.
16+
5) Increase Amount to Pool to at least 1. You can also check the 'Load More If None Left' box if you are unsure on how many you will need
17+
6) Access the Pooled Objects by using
18+
19+
```
20+
GameObject GO = ObjectPooler.Instance.GetGameObject(/*Index of the Pooled Object*/);
21+
//Make changes to your gameObject here
22+
```
23+
624
## In the Editor
725
![image](https://user-images.githubusercontent.com/32739337/102151045-4fa96100-3e48-11eb-9bed-7c8a8cb7eb8f.png)
826

@@ -23,7 +41,7 @@ Set the GameOject to be pooled
2341
If you enable Load More If None Left, then if the pool runs out of the object you want, it will create a new one and add it to the pool
2442

2543
## Debugging
26-
When Debug is enabled it gives more information on what is happening
44+
When Debug is enabled it gives more information on what the pool is doing
2745

2846
![image](https://user-images.githubusercontent.com/32739337/102151501-6ef4be00-3e49-11eb-8320-d3e5529cddf4.png)
2947
![image](https://user-images.githubusercontent.com/32739337/102151883-3b666380-3e4a-11eb-85bf-440009247c92.png)

0 commit comments

Comments
 (0)