Be patient..... we are fetching your source code.
Objective
Main objective of this blog post is to give you an idea Object Pooling in Unity
Object Pooling is nothing but pool or buffer of objects & reuse those objects from that pool. To rephrase it simply, we can say Object Pooling is a collection of reusable objects.
Step 1 Purpose
CPU overhead & memory space is required to instantiate & kill the objects. With the use of object pooling, we can reduce this overhead by using the older objects (which we have already created before) that are not in use at that point of time.
So, object pooling can enhance the performance when we are required to work with a huge amount of objects that are expensive to instantiate and each object is only needed for a short period of time.
Step 2 Application
You can use object pooling where same types of objects are needed frequently for short amount of time.
Step 3 Examples
- Objects related to path generation in endless game.
- Rifle in a shooting game.
- Coins which are used in may kind of games.
Step 4 Implementation
4.1 Create Object
Make one empty game-object named PoolManager. Then Assign ObjectPoolerSimple.cs script to that.
4.2 Create Cube Object
Make one CUBE as gameobject and assign it to Pooled Object field under ObjectPoolerSimple script in inspector.
4.3 Set Pool Amount
Set value of Pooled Amount (that many number of of clones will be made at the start) in inspector.
4.4 Pool Grow Property
Check the Is Pool Grow in inspector if you want to allow pool to grow during run time as more clone needed than Pooled Amount.
4.5 Max Grow Amount
Set value of Max Grow Amount in inspector. And must be more than Pooled Amount value.
Note
Pooled Object List shows the pool of objects as list in inspector. So basically it is used to trace the game-objects and length of pool-list i.e. the number of clones at run time.
I hope you find this blog is very helpful while working with Object Pooling in Unity3D. Let me know if you have any question regarding Unity 3D please comment here. I will reply you ASAP
Got an Idea of 3D Game Development ? What are you still waiting for? Contact us now and see the Idea live soon. Our company has been named as one of the best Unity 3D Game Development Company in India.
I am 3D Game developer with an aspiration of learning new technology and creating a bright future in Information Technology.
Integrating Media Player in iOS Using Swift