コード例 #1
0
        /// <summary>Renders the inverse of this corner for the border.</summary>
        public void RenderInverse(float cornerX, float cornerY)
        {
            // Grab the renderer:
            Renderman renderer = RoundCorners.Renderer;

            // Get the z-Index:
            float zIndex = renderer.Depth + 0.004f;

            // Grab the size of the outer arc array:
            int arcSize = OuterArc.Length;

            int currentIndex = 0;

            // Resolve the corner:
            Vector3 corner = renderer.PixelToWorldUnit(cornerX, cornerY, zIndex);

            // Ensure a batch is available:
            InverseBorder.SetupBatch(null, null);

            // For each inverse block:
            for (int i = 0; i < InverseBlocksRequired; i++)
            {
                // Get a block:
                MeshBlock block = InverseBorder.Add();

                // Set the clear colour:
                block.SetColour(Color.clear);

                // Always going to be space to sample two. Sample the first:
                Vector2 outerPoint = OuterArc[currentIndex];

                // Apply the triangle:
                block.VertexTopRight = corner;

                // Apply the first:
                block.VertexTopLeft = renderer.PixelToWorldUnit(cornerX + outerPoint.x, cornerY + outerPoint.y, zIndex);

                // Sample the second:
                outerPoint = OuterArc[currentIndex + 1];

                // Apply the second:
                block.VertexBottomLeft = renderer.PixelToWorldUnit(cornerX + outerPoint.x, cornerY + outerPoint.y, zIndex);

                if ((currentIndex + 2) >= arcSize)
                {
                    // Match the previous vertex:
                    block.VertexBottomRight = block.VertexBottomLeft;
                }
                else
                {
                    // Grab the next point along:
                    outerPoint = OuterArc[currentIndex + 2];

                    // Resolve and apply the third:
                    block.VertexBottomRight = renderer.PixelToWorldUnit(cornerX + outerPoint.x, cornerY + outerPoint.y, zIndex);
                }

                // Move index along:
                currentIndex += 2;
            }
        }