示例#1
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();
        }
示例#2
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);
        }
示例#3
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);
        }