Exemplo n.º 1
0
        private IEnumerator InitializeItem(VirtualScrollItem <T> item)
        {
            UnityUtility.SetActive(item, true);

            OnCreateItem(item);

            if (onCreateItem != null)
            {
                onCreateItem.OnNext(item);
            }

            // 初期化.
            var initializeYield = item.Initialize().ToObservable().ToYieldInstruction(false);

            while (!initializeYield.IsDone)
            {
                yield return(null);
            }

            if (initializeYield.HasError)
            {
                Debug.LogException(initializeYield.Error);
            }

            UnityUtility.SetActive(item, false);
        }
Exemplo n.º 2
0
        private void UpdateItem(VirtualScrollItem <T> item, int index)
        {
            switch (scrollType)
            {
            case ScrollType.Limited:
            {
                var enable = Contents != null && 0 <= index && index < Contents.Length;

                item.UpdateItem(index, Contents);
                UnityUtility.SetActive(item.gameObject, enable);
            }
            break;

            case ScrollType.Loop:
            {
                if (index < 0)
                {
                    index = Contents.Length - 1;
                }

                if (Contents.Length <= index)
                {
                    index = 0;
                }

                item.UpdateItem(index, Contents);
                UnityUtility.SetActive(item.gameObject, true);
            }
            break;
            }

            item.transform.name = index.ToString();
        }
Exemplo n.º 3
0
        private IObservable <Unit> UpdateItem(VirtualScrollItem <T> item, int index)
        {
            var observable = Observable.ReturnUnit();

            switch (scrollType)
            {
            case ScrollType.Limited:
            {
                observable = Observable.Defer(() => item.UpdateItem());
            }
            break;

            case ScrollType.Loop:
            {
                if (index < 0)
                {
                    index = Contents.Count - 1;
                }

                if (Contents.Count <= index)
                {
                    index = 0;
                }

                observable = Observable.Defer(() => item.UpdateItem());
            }
            break;
            }

            item.SetContent(index, Contents);

            UnityUtility.SetActive(item, item.Content != null);

            #if UNITY_EDITOR
            item.transform.name = index.ToString();
            #endif

            OnUpdateItem(item);

            if (onUpdateItem != null)
            {
                onUpdateItem.OnNext(item);
            }

            return(observable);
        }
Exemplo n.º 4
0
        private IEnumerator InitializeItem(VirtualScrollItem <T> item)
        {
            UnityUtility.SetActive(item, true);

            if (onCreateItem != null)
            {
                onCreateItem.OnNext(item);
            }

            // 初期化.
            var initializeYield = item.Initialize().ToYieldInstruction();

            while (!initializeYield.IsDone)
            {
                yield return(null);
            }

            UnityUtility.SetActive(item, false);
        }
Exemplo n.º 5
0
        private IObservable <Unit> UpdateItem(VirtualScrollItem <T> item, int index)
        {
            var observable = Observable.ReturnUnit();

            switch (scrollType)
            {
            case ScrollType.Limited:
            {
                var enable = Contents != null && 0 <= index && index < Contents.Length;

                observable = Observable.Defer(() => item.UpdateItem(index, Contents));
                UnityUtility.SetActive(item.gameObject, enable);
            }
            break;

            case ScrollType.Loop:
            {
                if (index < 0)
                {
                    index = Contents.Length - 1;
                }

                if (Contents.Length <= index)
                {
                    index = 0;
                }

                observable = Observable.Defer(() => item.UpdateItem(index, Contents));
                UnityUtility.SetActive(item.gameObject, true);
            }
            break;
            }

            item.transform.name = index.ToString();

            if (onUpdateItem != null)
            {
                onUpdateItem.OnNext(item);
            }

            return(observable);
        }