using UnityEngine; using System.Collections; /// /// This component is responsible for pre-creating the pools before they are needed. /// This is useful for objects like bullets, which are not part of a PooledLootTable /// (which would automatically pool the objects). /// public class PrePooler : MonoBehaviour { [System.Serializable] public class PrePoolInfo { public PoolObject prefab; public int quantity; } public PrePoolInfo[] prePools; void Awake() { PrePool(); NotificationCenter.AddListener(OnApplySkin, NotificationType.ApplySkin); } void OnDestroy() { NotificationCenter.RemoveListener(OnApplySkin, NotificationType.ApplySkin); } void OnApplySkin(Notification note) { DestroyImmediate(GameObject.Find("Pools")); Pool.ClearAllPools(); PrePool(); } void PrePool() { foreach (PrePoolInfo prePool in prePools) { Pool.Create(prePool.prefab, prePool.quantity); } } }