Skip to content

A base class to simplify object pooling using the new pooler provided in Unity 2021

License

Notifications You must be signed in to change notification settings

Matthew-J-Spencer/Object-Pooler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Unity Object Pooler

An abstract class aimed at simplifying the new object pooling workflow in Unity 2021. Video found here: https://youtu.be/7EZ2F-TzHYw

How to use

public class ShapeSpawner : PoolerBase<Shape> {
    [SerializeField] private Shape _shapePrefab;

    private void Start() {
        InitPool(_shapePrefab); // Initialize the pool

        var shape = Get(); // Pull from the pool
        Release(shape); // Release back to the pool
    }

    // Optionally override the setup components
    protected override void GetSetup(Shape shape) {
        base.GetSetup(shape);
        shape.transform.position = Vector3.zero;
    }
}

Drop a star if you found it useful and subscribe on YT :)

About

A base class to simplify object pooling using the new pooler provided in Unity 2021

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages