FairyGUI.NGraphics.DrawRect C# (CSharp) Method

DrawRect() public method

public DrawRect ( Rect vertRect, int lineSize, Color lineColor, Color fillColor, Color allColors ) : void
vertRect UnityEngine.Rect
lineSize int
lineColor UnityEngine.Color
fillColor UnityEngine.Color
allColors UnityEngine.Color
return void
        public void DrawRect(Rect vertRect, int lineSize, Color lineColor, Color fillColor, Color[] allColors)
        {
            if (lineSize == 0)
            {
                SetOneQuadMesh(new Rect(0, 0, vertRect.width, vertRect.height), new Rect(0, 0, 1, 1), fillColor, allColors);
            }
            else
            {
                Alloc(20);

                Rect rect;
                //left,right
                rect = Rect.MinMaxRect(0, 0, lineSize, vertRect.height);
                FillVerts(0, rect);
                rect = Rect.MinMaxRect(vertRect.width - lineSize, 0, vertRect.width, vertRect.height);
                FillVerts(4, rect);

                //top, bottom
                rect = Rect.MinMaxRect(lineSize, 0, vertRect.width - lineSize, lineSize);
                FillVerts(8, rect);
                rect = Rect.MinMaxRect(lineSize, vertRect.height - lineSize, vertRect.width - lineSize, vertRect.height);
                FillVerts(12, rect);

                //middle
                rect = Rect.MinMaxRect(lineSize, lineSize, vertRect.width - lineSize, vertRect.height - lineSize);
                FillVerts(16, rect);

                rect = new Rect(0, 0, 1, 1);
                int i;
                for (i = 0; i < 5; i++)
                    FillUV(i * 4, rect);

                Color32[] arr = this.colors;
                if (allColors != null)
                {
                    int colorCnt = allColors.Length;
                    for (i = 0; i < 20; i++)
                        arr[i] = allColors[i % colorCnt];
                }
                else
                {
                    Color32 col32 = lineColor;
                    for (i = 0; i < 16; i++)
                        arr[i] = col32;

                    col32 = fillColor;
                    for (i = 16; i < 20; i++)
                        arr[i] = col32;
                }

                FillTriangles();
                UpdateMesh();
            }
        }

Usage Example

 static public int DrawRect(IntPtr l)
 {
     try {
         FairyGUI.NGraphics self = (FairyGUI.NGraphics)checkSelf(l);
         UnityEngine.Rect   a1;
         checkValueType(l, 2, out a1);
         System.Int32 a2;
         checkType(l, 3, out a2);
         UnityEngine.Color a3;
         checkType(l, 4, out a3);
         UnityEngine.Color a4;
         checkType(l, 5, out a4);
         self.DrawRect(a1, a2, a3, a4);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }