Procedural Rect is a custom MaskableGraphic that renders smooth, anti-aliased rounded rectangles using a signed distance field (SDF) shader. It replaces sprite-based UI panels with a fully procedural alternative, supporting fills, outlines, inner shadows, outer shadows, and corner radii — all without any textures.
Color for each layer can be a flat color, a gradient, or inherited from the graphic's base color. Materials and gradient textures are pooled automatically so identical configurations share a single GPU resource.
This component is availabe to preview/test and will replace the background/border handling in version 2.0 once it's thoroughly tested in multiple environments.
Materials and gradient textures are reference-counted and shared across all ProceduralRect instances with identical settings, minimising draw calls and memory usage.
The component requires TexCoord1, TexCoord2, TexCoord3, Tangent, and Normal canvas shader channels. These are enabled automatically on the parent Canvas.
The component accepts a source image (sprite) graphic, so it can be used for masking. For example, you can assign a profile picture and increase the corner radius to get a perfect masking with better performance.
using UnityEngine;using Evo.UI;public class ProceduralRectExample : MonoBehaviour{ public ProceduralRect rect; void Start() { // Set a sprite rect.sprite = mySprite; // Rounded card with a white fill rect.fillColorMode = ProceduralRect.ColorMode.Custom; rect.fillColor = Color.white; rect.cornerRadius = new Vector4(16, 16, 16, 16); // Subtle drop shadow rect.outerShadowOffset = new Vector2(0, -4); rect.outerShadowSoftness = 12f; rect.outerShadowColor = new Color(0, 0, 0, 0.25f); // Thin outline rect.outlineWidth = 1f; rect.outlineColorMode = ProceduralRect.ColorMode.Custom; rect.outlineColor = new Color(0, 0, 0, 0.1f); // Reveal the shape with a radial wipe rect.clipMethod = ProceduralRect.ClipMethod.Radial360; rect.clipAmount = 0.75f; // Update the rect to apply some changes that require vertices or material to be updated rect.UpdateRect(); }}