文档

Unity Engine

Download Unity

Unity Engine

UI Toolkit runtime examples

Explore examples of runtime UI.
阅读时间1 分钟最后更新于 25 天前

This section provides examples that demonstrate how to create and manage UI elements at runtime using the UI Toolkit.

General examples

The following examples demonstrate how to create and manage runtime UI elements.

Topic

Description

Get started with runtime UIUse this example to get started with runtime UI.
Create a list view runtime UIUse ListView to create a simple character selection screen runtime UI.
Create a pie chart in the Editor and runtime UIUse the Vector API to create a pie chart.
Move elements at runtimeUse
style.translate
and
DynamicTransform
usage hints to move UI elements at runtime.

Panel Renderer script examples

The following examples demonstrate how to access, update, and add UI to a Panel Renderer component from a script.

Topics

Description

Display and update a progress bar every frameDisplay the player's health in a progress bar and update it every frame.
Keep UI state when the UI reloadsDisplay a HUD with the player's health and score, and keep the values when the UI reloads.
Add UI to an existing Panel Renderer from a scriptAdd notifications to the UI of a Panel Renderer from a separate script, and keep them visible when the UI reloads.