Ejemplo n.º 1
0
    public void Resize()
    {
        GetParentInfo();
        RectTransform rect = transform as RectTransform;

        if (DesignSize.x == 0)
        {
            DesignSize.x = 1;
        }
        if (DesignSize.y == 0)
        {
            DesignSize.y = 1;
        }
        ModelElement.Docking(rect, scaleType, psize, DesignSize);
        if (sizeType == SizeType.Anchor)
        {
            ModelElement.AnchorEx(rect, anchorType, new Vector2(margin.left, margin.right), pp, psize);
        }
        else if (sizeType == SizeType.Margin)
        {
            var mar = margin;
            if (parentType == ParentType.BangsScreen)
            {
                if (Scale.ScreenHeight / Scale.ScreenWidth > 2f)
                {
                    mar.top += 88;
                }
            }
            ModelElement.MarginEx(rect, mar, pp, psize);
        }
        else if (sizeType == SizeType.MarginRatio)
        {
            var mar = new Margin();
            mar.left  = margin.left * psize.x;
            mar.right = margin.right * psize.x;
            mar.top   = margin.top * psize.y;
            if (parentType == ParentType.BangsScreen)
            {
                if (Scale.ScreenHeight / Scale.ScreenWidth > 2f)
                {
                    mar.top += 88;
                }
            }
            mar.down = margin.down * psize.y;
            ModelElement.MarginEx(rect, mar, pp, psize);
        }
        for (int i = 0; i < transform.childCount; i++)
        {
            var ss = transform.GetChild(i).GetComponent <SizeScaleEx>();
            if (ss != null)
            {
                ss.Resize();
            }
        }
    }