public void Initialize(GameManager game, GameSettings settings) { _game = game; _stoneSprites = settings.StoneSprites; var size = settings.Size; _stonePool = new MonoPool <StoneController>(settings.StonePrefab, size.x * size.y); SetupCamera(size); }
private void Start() { onMessageRequest += GotMessageRequest; // Setup Message Action Queue messageQueue = new CoroutineQueue(this); messageQueue.StartLoop(); // Setup MessageText pool messagePool = gameObject.AddComponent <MessageTextPool>(); messagePool.objectPrefab = Resources.Load <MessageTextUI>("UI/MessageText"); }
private static MonoPool <MonoPoolable> GetPool(MonoPoolable prefab) { if (pools.ContainsKey(prefab)) { return(pools[prefab]); } else { MonoPool <MonoPoolable> newPool = new MonoPool <MonoPoolable>(prefab); pools.Add(prefab, newPool); return(newPool); } }
public T Spawn <T>(T prefab, Vector3 position, Quaternion rotation) where T : MonoPoolable { if (prefab == null) { throw new MissingReferenceException(); } MonoPool <MonoPoolable> pool = GetPool(prefab); T result = (T)pool.Spawn(position, rotation); result.transform.SetParent(transform); result.Prefab = prefab; return(result); }
public static T Fetch <T>(this MonoPool monoPool) where T : class { return(monoPool.Fetch(typeof(T)) as T); }
public void Despawn(MonoPoolable instance) { MonoPool <MonoPoolable> pool = GetPool(instance.Prefab); pool.Despawn(instance); }
private void Awake() { _selfChatHistoryItemPool = new MonoPool <SelfChatHistoryItemView>(_settings.CommonPoolSettings, _settings.SelfChatItemViewPrefab, contentTransform); _otherChatHistoryItemPool = new MonoPool <OtherChatHistoryItemView>(_settings.CommonPoolSettings, _settings.OtherChatHistoryItemView, contentTransform); }