Esempio n. 1
0
        override public void ModifyMesh(VertexHelper helper)
        {
            if (!Graphic || !(Graphic is RectangleGraphic) || Type == OutlineType.None)
            {
                return;
            }

            Rect rect;

            rect = Graphic.rectTransform.rect;

            if (GraphicUtil.IsEmpty(rect))
            {
                return;
            }

            float radius = (Graphic as RectangleGraphic).Radius;

            radius = Mathf.Min(radius, rect.width * 0.5f);
            radius = Mathf.Min(radius, rect.height * 0.5f);

            float size;

            size = radius * 2;

            List <UIVertex> verts;

            verts = ListPool <UIVertex> .Get();

            helper.GetUIVertexStream(verts);

            GraphicUtil.AddEllipseOutline(verts, new Rect(rect.xMin, rect.yMin, size, size), Color, Size, Type, 180, 90);
            GraphicUtil.AddEllipseOutline(verts, new Rect(rect.xMin, rect.yMax - size, size, size), Color, Size, Type, 90, 90);
            GraphicUtil.AddEllipseOutline(verts, new Rect(rect.xMax - size, rect.yMax - size, size, size), Color, Size, Type, 0, 90);
            GraphicUtil.AddEllipseOutline(verts, new Rect(rect.xMax - size, rect.yMin, size, size), Color, Size, Type, 270, 90);

            Rect horizontal = new Rect(rect.xMin, rect.yMin + radius, rect.width, rect.height - size);

            GraphicUtil.AddRectOutline(verts, horizontal, Color, Size, Type, EdgeType.Left);
            GraphicUtil.AddRectOutline(verts, horizontal, Color, Size, Type, EdgeType.Right);

            Rect vertical = new Rect(rect.xMin + radius, rect.yMin, rect.width - size, rect.height);

            GraphicUtil.AddRectOutline(verts, vertical, Color, Size, Type, EdgeType.Top);
            GraphicUtil.AddRectOutline(verts, vertical, Color, Size, Type, EdgeType.Bottom);

            helper.Clear();
            helper.AddUIVertexTriangleStream(verts);
            ListPool <UIVertex> .Put(verts);
        }
Esempio n. 2
0
        override public void ModifyMesh(VertexHelper helper)
        {
            if (!Graphic || !(Graphic is CapsuleGraphic) || Type == OutlineType.None)
            {
                return;
            }

            Rect rect;

            rect = Graphic.rectTransform.rect;

            if (GraphicUtil.IsEmpty(rect))
            {
                return;
            }

            List <UIVertex> verts;

            verts = ListPool <UIVertex> .Get();

            helper.GetUIVertexStream(verts);

            if (rect.height > rect.width)
            {
                GraphicUtil.AddEllipseOutline(verts, new Rect(rect.x, rect.yMax - rect.width, rect.width, rect.width), Color, Size, Type, 0, 180);
                GraphicUtil.AddRectOutline(verts, new Rect(rect.x, rect.y + rect.width * 0.5f, rect.width, rect.height - rect.width), Color, Size, Type, EdgeType.Left);
                GraphicUtil.AddEllipseOutline(verts, new Rect(rect.x, rect.yMin, rect.width, rect.width), Color, Size, Type, 180, 180);
                GraphicUtil.AddRectOutline(verts, new Rect(rect.x, rect.y + rect.width * 0.5f, rect.width, rect.height - rect.width), Color, Size, Type, EdgeType.Right);
            }
            else
            {
                GraphicUtil.AddRectOutline(verts, new Rect(rect.xMin + rect.height * 0.5f, rect.y, rect.width - rect.height, rect.height), Color, Size, Type, EdgeType.Top);
                GraphicUtil.AddEllipseOutline(verts, new Rect(rect.xMin, rect.y, rect.height, rect.height), Color, Size, Type, 90, 180);
                GraphicUtil.AddRectOutline(verts, new Rect(rect.xMin + rect.height * 0.5f, rect.y, rect.width - rect.height, rect.height), Color, Size, Type, EdgeType.Bottom);
                GraphicUtil.AddEllipseOutline(verts, new Rect(rect.xMax - rect.height, rect.y, rect.height, rect.height), Color, Size, Type, 270, 180);
            }

            helper.Clear();
            helper.AddUIVertexTriangleStream(verts);
            ListPool <UIVertex> .Put(verts);
        }