Пример #1
0
        private void RepositionDone()
        {
            UXGridComponent component = this.Root.GetComponent <UXGridComponent>();

            component.NGUIGrid.onReposition = null;
            this.recycleEnabled             = true;
            if (this.direction < 0)
            {
                component.NGUIScrollView.InvalidateBounds();
                Bounds bounds = component.NGUIScrollView.bounds;
                float  num    = component.NGUIScrollView.panel.finalClipRegion.w * 0.5f;
                float  num2   = bounds.min.y + num;
                float  num3   = bounds.max.y - num;
                if (component.NGUIScrollView.panel.clipping == UIDrawCall.Clipping.SoftClip)
                {
                    num2 -= component.NGUIScrollView.panel.clipSoftness.y;
                    num3 += component.NGUIScrollView.panel.clipSoftness.y;
                }
                float num4 = Mathf.Abs(num2 - num3);
                float num5 = component.CellHeight / num4;
                this.myGrid.Scroll(this.myGrid.GetCurrentScrollPosition(true) + num5);
            }
        }
Пример #2
0
        private UXGrid CreateGrid(GameObject gameObject, UIGrid nguiGrid)
        {
            UXGridComponent uXGridComponent = gameObject.GetComponent <UXGridComponent>();

            if (uXGridComponent != null)
            {
                uXGridComponent.Grid = null;
                UnityEngine.Object.Destroy(uXGridComponent);
            }
            uXGridComponent                   = gameObject.AddComponent <UXGridComponent>();
            uXGridComponent.NGUIGrid          = nguiGrid;
            uXGridComponent.NGUIPanel         = gameObject.transform.parent.GetComponent <UIPanel>();
            uXGridComponent.NGUIScrollView    = gameObject.transform.parent.GetComponent <UIScrollView>();
            uXGridComponent.NGUICenterOnChild = gameObject.GetComponent <UICenterOnChild>();
            if (uXGridComponent.NGUICenterOnChild == null)
            {
                uXGridComponent.NGUICenterOnChild = gameObject.transform.parent.GetComponent <UICenterOnChild>();
            }
            UXGrid uXGrid = new UXGrid(this, this.uxCamera, uXGridComponent);

            uXGridComponent.Grid = uXGrid;
            this.AddElement(gameObject.name, uXGrid);
            return(uXGrid);
        }
Пример #3
0
        private void Recycle(int direction)
        {
            this.direction = direction;
            UXGridComponent component = this.Root.GetComponent <UXGridComponent>();

            if (component.NGUIScrollView.panel.isAnchoredVertically)
            {
                Transform anchor = null;
                component.NGUIScrollView.panel.SetAnchor(anchor);
            }
            int num;

            if (direction > 0)
            {
                num = this.firstLoadedItem;
            }
            else
            {
                num = this.lastLoadedItem;
            }
            UIScrollView uIScrollView          = NGUITools.FindInParents <UIScrollView>(this.myGrid.Root);
            float        currentScrollPosition = this.myGrid.GetCurrentScrollPosition(true);
            float        y = uIScrollView.bounds.size.y;

            this.CleanupUIForItem(this.listItems[num].Cookie);
            this.listItems[num].UIItem.Visible = false;
            this.myGrid.RemoveItem(this.listItems[num].UIItem);
            ListItem  listItem = this.listItems[num];
            UXElement uIItem   = listItem.UIItem;

            listItem.UIItem       = null;
            this.listItems[num]   = listItem;
            this.firstLoadedItem += direction;
            this.lastLoadedItem  += direction;
            int num2;

            if (direction > 0)
            {
                num2 = this.lastLoadedItem;
            }
            else
            {
                num2 = this.firstLoadedItem;
            }
            listItem             = this.listItems[num2];
            listItem.UIItem      = uIItem;
            this.listItems[num2] = listItem;
            this.RequestUIForItem(this.listItems[num2].Cookie, num2, num);
            float num3 = y - component.CellHeight;
            float num4 = num3 - component.NGUIScrollView.panel.finalClipRegion.w;
            float num5 = y - component.NGUIScrollView.panel.finalClipRegion.w;
            float num6;

            if (direction > 0)
            {
                num6 = (component.CellHeight - (float)direction) / num4;
            }
            else
            {
                num6 = (float)(-(float)direction) / num4;
            }
            this.myGrid.Scroll(currentScrollPosition / (num4 / num5) - num6);
            component.NGUIGrid.onReposition = new UIGrid.OnReposition(this.RepositionDone);
            this.recycleEnabled             = false;
        }