# generateVisualContent

> Delegate function to generate the visual content of a visual element.

## Definition

* **Type:** Property
* **Namespace:** [UnityEngine.UIElements](/engine/6000.6/script-reference/unityengine/uielements.md)
* **Assembly:** UnityEngine.UIElementsModule

```csharp
public Action<MeshGenerationContext> generateVisualContent { get; set; }
```

### Remarks

Use this delegate to generate custom geometry in the content region of the [VisualElement](/engine/6000.6/script-reference/unityengine/uielements/visualelement.md). You can use the [\_painter2D](/engine/6000.6/script-reference/unityengine/uielements/meshgenerationcontext/painter2d.md) object to generate visual content, or use the [MeshGenerationContext.Allocate](/engine/6000.6/script-reference/unityengine/uielements/meshgenerationcontext/allocate.md) method to manually allocate a mesh and then fill in the vertices and indices.

This delegate is called during the initial creation of the [VisualElement](/engine/6000.6/script-reference/unityengine/uielements/visualelement.md) and whenever a repaint is needed. This delegate isn't called on every frame refresh. To force a repaint, call [VisualElement.MarkDirtyRepaint](/engine/6000.6/script-reference/unityengine/uielements/visualelement/markdirtyrepaint.md).

**Note**: When you execute code in a handler to this delegate, don't update any property of the [VisualElement](/engine/6000.6/script-reference/unityengine/uielements/visualelement.md), as this can alter the generated content and cause unwanted side effects, such as lagging or missed updates. To avoid this, treat the [VisualElement](/engine/6000.6/script-reference/unityengine/uielements/visualelement.md) as read-only within the delegate.

Additional Resources: [MeshGenerationContext](/engine/6000.6/script-reference/unityengine/uielements/meshgenerationcontext.md)
