Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GenerateVisualContentAttribute

Declares a static method of a VisualElementComponentAttribute struct as a painter that contributes to the owner element's _generateVisualContent.
Read time 3 minutesLast updated 10 days ago

Definition

[AttributeUsage(AttributeTargets.Method, Inherited = false)]public class GenerateVisualContentAttribute : Attribute

Remarks

The method must be
static void M(ref T self, <see cref="UnityEngine.UIElements.MeshGenerationContext"></see> mgc)
. The source generator hooks it into the owner's
generateVisualContent
when the component is added and unhooks it when the component is removed, and requests an initial repaint. Geometry changes re-run the painter through the engine, and [StyleProperty] changes repaint via the generated style handler, so no extra callbacks are needed.

Inheritance

Inherited Members