Version: 2023.2+
This example demonstrates how to create custom controls and use the Vector API to draw visual content onto a visual element.
この例では、ローディングバーの代わりに進行状況を表示するカスタムコントロールを作成します。進捗インジケーターは、パーセンテージを表示するラベルの周囲に、部分的に塗りつぶされた輪で進捗値を表示します。0 から 100 までの値で表示され、それにより輪がどの程度塗りつぶされるかが決定されます。
You can find the completed files that this example creates in this GitHub repository.
このガイドは、Unity エディター、UI Toolkit、および C# スクリプトに精通している開発者を対象としています。始める前に、以下をよく理解してください。
Create a C# script to define a RadialProgress
visual element and a C# script to define the custom mesh. Style the visual element with a USS file.
radial-progress
というフォルダーを作成し、ファイルを保存します。radial-progress
folder, create a C# script named RadialProgress.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
という名前の UI Document を作成します。RadialProgressExample.uxml
をダブルクリックして UI Builder で開きます。RadialProgress.uss
as the existing USS.radial-progress
と入力します。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: