# CaptureToPNG(VisualElement, string)

> Renders the element's panel, captures the visual content of element, and saves it to disk as a PNG file.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor.UIElements](/engine/6000.7/script-reference/unityeditor/uielements.md)
* **Assembly:** UnityEditor

```csharp
public static void CaptureToPNG(this VisualElement element, string path)
```

### Parameters

**** (\[VisualElement]\(/engine/6000.7/script-reference/unityengine/uielements/visualelement)): The element to capture. It must belong to a panel.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The destination file path. This function creates the directory if it does not exist.

### Remarks

This method repaints the whole panel before it captures content. This method calls [VisualElementCaptureExtensions.CaptureToRenderTexture](/engine/6000.7/script-reference/unityengine/uielements/visualelementcaptureextensions/capturetorendertexture.md), then encodes the result as a PNG, and releases the intermediate texture.
