コード例 #1
0
ファイル: CutGridBG.cs プロジェクト: tuita520/u3dmmorpg
        private void Tick()
        {
            itemCount = Grid.GetShowCount();
            if (itemCount == lastCount)
            {
                return;
            }

            if (itemCount == 0)
            {
                BackGround.width  = (int)Grid.cellWidth + Padding * 2;
                BackGround.height = (int)Grid.cellHeight + Padding * 2;
                return;
            }

            lastCount = itemCount;

            if (Grid.arrangement == UIGridSimple.Arrangement.Horizontal)
            {
                var perLine = Grid.maxPerLine;

                var widthCount = 0;

                if (itemCount >= perLine)
                {
                    widthCount = perLine;
                }
                else
                {
                    widthCount = itemCount % perLine;
                }

                BackGround.width = widthCount * (int)Grid.cellWidth + Padding * 2;


                var maxPerHeight = (int)(Grid.maxlenth / Grid.cellHeight);

                var heightCount = itemCount / Grid.maxPerLine;

                if (itemCount % Grid.maxPerLine != 0)
                {
                    heightCount += 1;
                }

                if (heightCount > maxPerHeight)
                {
                    heightCount = maxPerHeight;
                }

                BackGround.height = heightCount * (int)Grid.cellHeight + Padding * 2;
            }
        }
コード例 #2
0
ファイル: CutGridBG.cs プロジェクト: pikaqiufk/Client
        // Update is called once per frame
        private void Update()
        {
        #if !UNITY_EDITOR
            try
            {
        #endif
            itemCount = Grid.GetShowCount();
            if (itemCount == lastCount)
            {
                return;
            }

            if (itemCount == 0)
            {
                BackGround.width  = (int)Grid.cellWidth + Padding * 2;
                BackGround.height = (int)Grid.cellHeight + Padding * 2;
                return;
            }

            lastCount = itemCount;

            if (Grid.arrangement == UIGridSimple.Arrangement.Horizontal)
            {
                var perLine = Grid.maxPerLine;

                var widthCount = 0;

                if (itemCount >= perLine)
                {
                    widthCount = perLine;
                }
                else
                {
                    widthCount = itemCount % perLine;
                }

                BackGround.width = widthCount * (int)Grid.cellWidth + Padding * 2;


                var maxPerHeight = (int)(Grid.maxlenth / Grid.cellHeight);

                var heightCount = itemCount / Grid.maxPerLine;

                if (itemCount % Grid.maxPerLine != 0)
                {
                    heightCount += 1;
                }

                if (heightCount > maxPerHeight)
                {
                    heightCount = maxPerHeight;
                }

                BackGround.height = heightCount * (int)Grid.cellHeight + Padding * 2;
            }
        #if !UNITY_EDITOR
        }

        catch (Exception ex)
        {
            Logger.Error(ex.ToString());
        }
        #endif
        }