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

35 行
871 B

using UnityEngine;
using UnityEngine.UIElements;
namespace UnityRoyale
{
[RequireComponent(typeof(UIDocument))]
public class GameScreen : MonoBehaviour
{
private VisualElement cardPanel;
void OnEnable()
{
cardPanel = GetComponent<UIDocument>().rootVisualElement.Q("cardpanel");
cardPanel.style.display = DisplayStyle.None;
}
public VisualElement GetCardPanelRoot()
{
// Enable the screen with the first access to the panel, as it means we want to show cards.
ShowGameScreen();
return cardPanel;
}
public void HideGameScreen()
{
cardPanel.style.display = DisplayStyle.None;
}
private void ShowGameScreen()
{
cardPanel.style.display = DisplayStyle.Flex;
}
}
}