This commit is contained in:
CortexCore
2024-03-31 23:31:00 +08:00
parent e179d2eb53
commit b7b89ee71a
641 changed files with 31286 additions and 22134 deletions

View File

@@ -22,7 +22,7 @@ namespace BITKit.UX
this.visualElement = visualElement;
contextLabel = visualElement.Q<Label>(UXConstant.ContextLabel);
titleLabel = visualElement.Q<Label>(UXConstant.TitleLabel);
numberLabel = visualElement.Q<Label>(UXConstant.TitleLabel);
numberLabel = visualElement.Q<Label>(UXConstant.NumberLabel);
descriptionLabel = visualElement.Q<Label>(UXConstant.DescriptionLabel);
button = visualElement.Q<Button>(UXConstant.MainButton);
secButton = visualElement.Q<Button>(UXConstant.SecButton);
@@ -33,7 +33,15 @@ namespace BITKit.UX
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)) ;
var radialProgress = visualElement.Q<RadialProgress>();
if (radialProgress is not null)
{
radialProgress.progress = Mathf.Clamp((int)(process*100), 0, 100);
}
else
{
visualElement.Q(UXConstant.ProcessBarFill).style.width =Length.Percent(Mathf.Clamp(process * 100,0,100)) ;
}
}
}
}

View File

@@ -0,0 +1,62 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.UIElements;
namespace BITKit.UX
{
public class UXToolTips : MonoBehaviour
{
private VisualElement root;
private Label label;
private void Start()
{
root = GetComponent<UIDocument>().rootVisualElement;
label = root.Q<Label>();
}
private void Update()
{
var tooltip = CurrentToolTip(root.panel);
if (tooltip != "")
{
var mouse = Mouse.current;
if (mouse is null) return;
var mousePos = mouse.position.ReadValue();
mousePos.y = Screen.height - mousePos.y;
var pos =RuntimePanelUtils.ScreenToPanel(label.panel,mousePos);
pos.x += 24;
if (pos.x + label.layout.width > label.panel.visualTree.layout.width)
{
//pos.x = label.panel.visualTree.layout.width - label.layout.width - label.layout.width;
pos.x-=label.layout.width+48;
}
label.visible = true;
label.text = tooltip;
label.transform.position = pos;
}
else
{
label.visible = false;
}
}
private string CurrentToolTip(IPanel panel)
{
// https://docs.unity3d.com/2022.2/Documentation/Manual/UIE-faq-event-and-input-system.html
if (!EventSystem.current.IsPointerOverGameObject()) return "";
var screenPosition = Input.mousePosition;
screenPosition.y = Screen.height - screenPosition.y;
VisualElement ve = panel.Pick(RuntimePanelUtils.ScreenToPanel(panel, screenPosition));
return ve == null ? "" : ve.tooltip;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 98955702b98a11c4e8563958148f5719
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: