Class RectSizeToUV
A UI mesh effect that writes the pixel dimensions of a RectTransform into a specified UV channel on every vertex, allowing a shader to access the element's real size at runtime.
[RequireComponent(typeof(CanvasRenderer))]
public class RectSizeToUV : BaseMeshEffect
Inheritance
Remarks
Attach this component alongside any UnityEngine.UI.Graphic (e.g. an Image) whose shader needs to know the exact width and height in pixels — useful for SDF-based rounded-rect or dialogue-bubble shaders that must scale correctly with the UI element.
Methods
ModifyMesh(VertexHelper)
Injects the RectTransform pixel size into every vertex's selected UV channel so that the material shader can access the element's actual dimensions.
public override void ModifyMesh(VertexHelper vh)
Parameters
| Name | Type | Description |
|---|---|---|
vh | VertexHelper | The vertex helper whose vertices will be modified. |