Exemplo n.º 1
0
        public void CalculateExtenderBorderVertices(ExtenderBorderInfo info, ref Vector3 v1, ref Vector3 v2)
        {
            v1.z = v2.z = rectTransform.localPosition.z;
            var half = rectTransform.sizeDelta / 2;

            switch (info.Border)
            {
            case ExtenderBorderEnum.Bottom:
                v1.x = -half.x + info.CutoffNear;
                v2.x = half.x - info.CutoffFar;
                v1.y = v2.y = -half.y + info.Margin;
                break;

            case ExtenderBorderEnum.Left:
                v1.y = -half.y + info.CutoffNear;
                v2.y = half.y - info.CutoffFar;
                v1.x = v2.x = -half.x + info.Margin;
                break;

            case ExtenderBorderEnum.Right:
                v1.y = -half.y + info.CutoffNear;
                v2.y = half.y - info.CutoffFar;
                v1.x = v2.x = half.x - info.Margin;
                break;

            case ExtenderBorderEnum.Top:
                v1.x = -half.x + info.CutoffNear;
                v2.x = half.x - info.CutoffFar;
                v1.y = v2.y = half.y - info.Margin;
                break;
            }
        }
        public void CalculateEditorBorderVertices(ExtenderBorderInfo info, ref Vector3 v1, ref Vector3 v2)
        {
            var rect = target.rectTransform.rect;

            v1.z = v2.z = target.rectTransform.localPosition.z;
            switch (info.Border)
            {
            case ExtenderBorderEnum.Bottom:
                v1.x = rect.xMin + info.CutoffNear;
                v2.x = rect.xMax - info.CutoffFar;
                v1.y = v2.y = rect.yMin + info.Margin;
                break;

            case ExtenderBorderEnum.Left:
                v1.y = rect.yMin + info.CutoffNear;
                v2.y = rect.yMax - info.CutoffFar;
                v1.x = v2.x = rect.xMin + info.Margin;
                break;

            case ExtenderBorderEnum.Right:
                v1.y = rect.yMin + info.CutoffNear;
                v2.y = rect.yMax - info.CutoffFar;
                v1.x = v2.x = rect.xMax - info.Margin;
                break;

            case ExtenderBorderEnum.Top:
                v1.x = rect.xMin + info.CutoffNear;
                v2.x = rect.xMax - info.CutoffFar;
                v1.y = v2.y = rect.yMax - info.Margin;
                break;
            }
        }