com.alicizax.unity.packagem.../Editor/PackageManager/Window/PackageBottomStateBar.cs

46 lines
1.4 KiB
C#
Raw Normal View History

2025-02-20 10:48:57 +08:00
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
namespace AlicizaX.PackageManager.Editor
{
internal class PackageBottomStateBar : VisualElement
{
private readonly Label stateLabel;
private readonly Button btnRefresh;
public PackageBottomStateBar()
{
style.flexDirection = FlexDirection.Row;
style.flexShrink = 1;
style.justifyContent = Justify.FlexStart;
style.height = Length.Percent(5);
style.backgroundColor = new Color(0.2509804f, 0.2509804f, 0.2509804f);
style.borderTopWidth = 1;
stateLabel = new Label();
stateLabel.name = "stateLabel";
2025-02-20 11:44:00 +08:00
stateLabel.text = EditorPrefs.GetString("PackageUpdateDate", "");
2025-02-20 10:48:57 +08:00
stateLabel.style.alignSelf = Align.Center;
stateLabel.style.marginLeft = new Length(2, LengthUnit.Pixel);
stateLabel.style.flexGrow = 1; // 让 Label 占据剩余空间
Add(stateLabel);
2025-02-20 13:15:18 +08:00
btnRefresh = new Button(OnBtnRefreshClick);
2025-02-20 10:48:57 +08:00
btnRefresh.name = "btnRefresh";
btnRefresh.style.maxHeight = 30;
Image icon = new Image();
icon.image = EditorGUIUtility.IconContent("d_Refresh").image;
btnRefresh.Add(icon);
Add(btnRefresh);
}
private void OnBtnRefreshClick()
{
2025-02-20 13:15:18 +08:00
UpdateAllPackageHelper.UpdatePackages();
2025-02-20 10:48:57 +08:00
}
}
}