Version: 2023.2+
This example demonstrates how to use the Mesh API to draw visual content onto a visual element.
Note: The Mesh API is a tool for advanced users. In version 2022.1 and later, if you only want to generate simple geometry, use the Vector API instead. For more information, see Use Vector API to create a radial progress indicator.
This example creates a custom control that displays progress, as an alternative to a loading bar. The progress indicator displays a progress value in a partially filled ring around a label that displays the percentage. It supports a value between 0 and 100, which determines how much of the ring is filled.
You can find the completed files that this example creates in this GitHub repository.
This guide is for developers familiar with the Unity Editor, UI Toolkit, and C# scripting. Before you start, get familiar with the following:
Create a C# script to define the RadialProgress
class, and expose the control to UXML and UI Builder.
radial-progress
to store your files.radial-progress
folder, create a C# scrip named RadialProgress.cs
with the following content:Create a C# script named EllipseMesh.cs
with the following content:
Create a USS file named RadialProgress.uss
with the following content:
Use UI Builder to add the control and apply the USS stylesheet. Test the control with different Progress
values.
RadialProgressExample.uxml
.RadialProgressExample.uxml
to open it in the UI Builder.RadialProgress.uss
as the existing USS.radial-progress
in the Name box.Create a C# MonoBehaviour script to update the Progress
property of the control with dynamic values for demo purposes. In the radial-progress
folder, create a C# MonoBehaviour named RadialProgressComponent.cs
with the following content: