2019/12/25에 해당하는 글 1

Unity GameObject Pooling

유니티 & C#|2019. 12. 25. 01:07

https://github.com/wakeup5/Unity-GameObject-Pooling

간단히 게임오브젝트 풀을 생성하고 불러올 수 있는 라이브러리이다.

사용방법

// Pool of GameObject
public GameObject original1;

IPool<GameObject> pool = Pool.OfGameObject(original1);
pool.ActivateOne(Vector3.zero, Quaternion.identity);

// Pool of MonoBehaviour
public Monster original2; // public class Monster : MonoBehaviour

IPool<Monster> pool = Pool.OfBehaviour(original2);
pool.ActivateOne();

// Pool of Poolable
public Bullet original3; // public class Bullet : Poolable (: MonoBahaviour)

var instance = Pool.OfPoolable(original3).ActivateOne(); // 바로 호출하여 사용 가능
instance.Pool; // Pool에 접근 가능.
instance.Original; // Original Prefab에 접근 가능.

// for RectTransform
public Text floatingDamage;
public RectTransform uiParent;

var pool = Pool.OfBehaviour(floatingDamage, uiParant); // create objects on RectTransform;
pool.ActivateOne();

댓글()