2023-06-05 19:57:17 +08:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace BITKit.UX
|
|
|
|
{
|
|
|
|
public class UXContainer
|
|
|
|
{
|
|
|
|
public static implicit operator VisualElement(UXContainer self) => self.visualElement;
|
2023-08-11 23:57:37 +08:00
|
|
|
public readonly Label contextLabel;
|
|
|
|
public readonly Label titleLabel;
|
|
|
|
public readonly Label descriptionLabel;
|
|
|
|
public readonly Label numberLabel;
|
|
|
|
public readonly Button button;
|
|
|
|
public readonly Button secButton;
|
|
|
|
public readonly VisualElement visualElement;
|
|
|
|
public readonly VisualElement container;
|
|
|
|
public readonly VisualElement icon;
|
2023-08-23 01:59:26 +08:00
|
|
|
public readonly Toggle toggle;
|
2023-06-05 19:57:17 +08:00
|
|
|
public UXContainer(VisualElement visualElement)
|
|
|
|
{
|
|
|
|
this.visualElement = visualElement;
|
2023-08-11 23:57:37 +08:00
|
|
|
contextLabel = visualElement.Q<Label>(UXConstant.ContextLabel);
|
2023-06-05 19:57:17 +08:00
|
|
|
titleLabel = visualElement.Q<Label>(UXConstant.TitleLabel);
|
|
|
|
numberLabel = visualElement.Q<Label>(UXConstant.TitleLabel);
|
|
|
|
descriptionLabel = visualElement.Q<Label>(UXConstant.DescriptionLabel);
|
|
|
|
button = visualElement.Q<Button>(UXConstant.MainButton);
|
|
|
|
secButton = visualElement.Q<Button>(UXConstant.SecButton);
|
|
|
|
icon = visualElement.Q(UXConstant.Icon);
|
2023-08-11 23:57:37 +08:00
|
|
|
container = this.visualElement.Q(UXConstant.ContextContainer);
|
2023-08-23 01:59:26 +08:00
|
|
|
toggle = this.visualElement.Q<Toggle>(UXConstant.Toggle);
|
2023-08-11 23:57:37 +08:00
|
|
|
}
|
|
|
|
public T Get<T>(int index) where T : VisualElement => visualElement.Q<T>($"{typeof(T).Name}--{index}");
|
|
|
|
public void SetProcess(float process)
|
|
|
|
{
|
|
|
|
visualElement.Q(UXConstant.ProcessBarFill).style.width =Length.Percent(Mathf.Clamp(process * 100,0,100)) ;
|
2023-06-05 19:57:17 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|