com.alicizax.unity.packagem.../Editor/PackageManager/Window/PackageBottomStateBar.cs
2025-02-20 13:15:18 +08:00

46 lines
1.4 KiB
C#

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";
stateLabel.text = EditorPrefs.GetString("PackageUpdateDate", "");
stateLabel.style.alignSelf = Align.Center;
stateLabel.style.marginLeft = new Length(2, LengthUnit.Pixel);
stateLabel.style.flexGrow = 1; // 让 Label 占据剩余空间
Add(stateLabel);
btnRefresh = new Button(OnBtnRefreshClick);
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()
{
UpdateAllPackageHelper.UpdatePackages();
}
}
}