private int _count; // Кол-во обрабатываемых вещей. #region Public Methods public void StartLoading() { A.Assert((pools == null || pools.Length == 0), "Pool Loader is empty!", true); var root = new GameObject(); root.name = "Pools"; AntPoolManager.SetParent(root.transform); _count = 0; _current = 0; for (int i = 0, n = pools.Length; i < n; i++) { _count += pools[i].items.Length; } _currentPoolIndex = 0; _currentPool = pools[_currentPoolIndex]; if (EventStart != null) { EventStart(this, 0.0f); } StartCoroutine(DoProgress()); }
private IEnumerator DoProgress() { while (true) { int n = (_current + countPerStep > _count) ? _count - _current : countPerStep; for (int i = 0; i < n; i++) { if (_currentItemIndex == _currentPool.items.Length) { _currentPoolIndex++; _currentPool = pools[_currentPoolIndex]; _currentItemIndex = 0; } AntPoolManager.AddPool(_currentPool.items[_currentItemIndex].prefab, _currentPool.items[_currentItemIndex].initialSize); _currentItemIndex++; _current++; } if (EventProcess != null) { EventProcess(this, (float)_current / (float)_count); } if (_current < _count) { yield return(null); } else { break; } } if (EventComplete != null) { EventComplete(this, 1.0f); } }