Sample project to showcase the use of UI Toolkit for Runtime based on the Unity Royale project.
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

39 行
1.1 KiB

using UnityEngine;
using UnityEngine.UIElements;
namespace UnityRoyale
{
public class UIManager : MonoBehaviour
{
[SerializeField] private GameScreen gameScreen = default;
[SerializeField] private EndScreen endScreenPrefab = default;
[SerializeField] private HealthBar healthBarPrefab = default;
[SerializeField] private Transform healthBarContainer = default;
public void AddHealthUI(ThinkingPlaceable p)
{
var healthBar = Instantiate(healthBarPrefab, healthBarContainer);
p.healthBar = healthBar;
healthBar.Initialize(p);
}
public void RemoveHealthUI(ThinkingPlaceable p)
{
if (p.healthBar)
{
Destroy(p.healthBar.gameObject);
}
}
public VisualElement GetCardPanelRoot()
{
return gameScreen.GetCardPanelRoot();
}
public void ShowGameOverUI(string winnerTeamName)
{
gameScreen.HideGameScreen();
EndScreen.Show(endScreenPrefab, transform, winnerTeamName);
}
}
}