示例#1
0
        protected virtual void OnLoadingStarted(EventsChannel.Promise promise, string message)
        {
            // Create an item
            var newItem = _pool.GetResource();

            newItem.Id           = promise.EventId;
            newItem.Message.text = message;

            // Move item to the list
            newItem.transform.SetParent(ItemsGroup.transform, false);
            newItem.transform.SetAsLastSibling();
            newItem.gameObject.SetActive(true);

            // Store the item
            _visibleLoadingItems.Add(newItem.Id, newItem);
        }
示例#2
0
        protected virtual void OnLoadingFinished(EventsChannel.Promise promise)
        {
            LoadingUiItem item;

            _visibleLoadingItems.TryGetValue(promise.EventId, out item);

            if (item == null)
            {
                return;
            }

            // Remove the item
            _visibleLoadingItems.Remove(promise.EventId);
            _pool.Store(item);

            // if everything is done loading, we can disable the loading view
            if (_visibleLoadingItems.Count == 0)
            {
                gameObject.SetActive(false);
            }
        }
示例#3
0
        protected virtual void HandleEvent(EventsChannel.Promise promise, string message)
        {
            if (_visibleLoadingItems == null)
            {
                _visibleLoadingItems = new Dictionary <int, LoadingUiItem>();
            }

            if (_pool == null)
            {
                _pool = new GenericPool <LoadingUiItem>(LoadingItemPrefab);
            }

            // If this is the first item to get to the list
            if (_visibleLoadingItems.Count == 0)
            {
                gameObject.SetActive(true);
            }

            OnLoadingStarted(promise, message ?? DefaultLoadingMessage);
            promise.Subscribe(OnLoadingFinished);
        }