Ejemplo n.º 1
0
    protected override void CalcContentCoordination()
    {
        var column = -1;
        var maxY   = 0;

        for (int index = 0, max = DataProvider.Count; index < max; index++)
        {
            var data   = DataProvider[index];
            var prefab = GetPrefab(data.PrefabName);

            var size = PrefabSizeByName[prefab.name];

            var width  = (int)size.x;
            var height = (int)size.y;

            if (column == -1)
            {
                column = (int)(ViewComponent.RectTransform.rect.width / width);
            }

            data.X = (index % column) * width;
            data.Y = (index / column) * height;

            data.Min = data.Y;
            data.Max = data.Y + height;

            maxY = data.Max;
        }

        ViewComponent.SetContentRectTransform(ViewComponent.Content.sizeDelta.x, maxY);

        base.CalcContentCoordination();
    }
Ejemplo n.º 2
0
    protected override void CalcContentCoordination()
    {
        var sum    = 0;
        var origin = ViewComponent.Origin;

        for (int index = 0, max = DataProvider.Count; index < max; index++)
        {
            var data   = DataProvider[index];
            var prefab = GetPrefab(data.PrefabName);

            var size   = PrefabSizeByName[prefab.name];
            var width  = (int)size.x;
            var height = (int)size.y;

            data.Min = sum;
            switch (origin)
            {
            case ViewHelper.Origin.Top:
            case ViewHelper.Origin.Bottom:
                data.Max = sum + height;
                sum     += height;
                break;

            case ViewHelper.Origin.Left:
            case ViewHelper.Origin.Right:
                data.Max = sum + width;
                sum     += width;
                break;
            }
        }

        var deltaX = ViewComponent.Content.sizeDelta.x;
        var deltaY = ViewComponent.Content.sizeDelta.y;

        switch (origin)
        {
        case ViewHelper.Origin.Top:
        case ViewHelper.Origin.Bottom:
            deltaY = sum;
            break;

        case ViewHelper.Origin.Left:
        case ViewHelper.Origin.Right:
            deltaX = sum;
            break;
        }

        ViewComponent.SetContentRectTransform(deltaX, deltaY);

        base.CalcContentCoordination();
    }