public static T Create <T>(T prefab, MonoPoolType poolType = MonoPoolType.Lasting, int initPoolSize = DEFAULT_INIT_POOL_SIZE, int maxPoolSize = DEFAULT_MAX_POOL_SIZE) where T : MonoBehaviour, IRecycleable { T item = MonoPool <T> .instance .SetType(poolType) .Init(() => { return(GameObject.Instantiate(prefab)); }, DEFAULT_INIT_POOL_SIZE, DEFAULT_MAX_POOL_SIZE) .Create(); return(item); }
public MonoPool <T> SetType(MonoPoolType monoPoolType) { if (monoPoolType != poolType) { poolType = monoPoolType; if (poolType == MonoPoolType.Lasting) { MonoPoolManager.instance.UnRegister(OnSceneUnloaded); } else { MonoPoolManager.instance.Register(OnSceneUnloaded); } } return(this); }