UI系统优化
This commit is contained in:
@@ -55,16 +55,19 @@ namespace BaseGames.Editor.Modules
|
||||
|
||||
if (_selected == null) return;
|
||||
|
||||
// Stats Card
|
||||
// Stats Card(复用 SkillModule 共享构建方法)
|
||||
var statsCard = BuildStatsCard(_selected);
|
||||
container.Add(statsCard);
|
||||
|
||||
// 操作按钮行
|
||||
var toolbar = BuildActionBar(_selected);
|
||||
container.Add(toolbar);
|
||||
// 操作按钮行(复用 BuildStandardActionBar,统一按钮样式)
|
||||
container.Add(SkillModule.BuildStandardActionBar<WeaponSO>(
|
||||
_selected, Folder, Prefix,
|
||||
created => _listPane.Refresh(created),
|
||||
cloned => _listPane.Refresh(cloned),
|
||||
() => _listPane.Refresh(null)));
|
||||
|
||||
// 分隔线
|
||||
container.Add(MakeDivider());
|
||||
container.Add(SkillModule.MakeDivider());
|
||||
|
||||
// Inspector
|
||||
var insp = new InspectorElement(_selected); container.Add(insp);
|
||||
@@ -92,92 +95,12 @@ namespace BaseGames.Editor.Modules
|
||||
|
||||
private static VisualElement BuildStatsCard(WeaponSO w)
|
||||
{
|
||||
var card = new VisualElement();
|
||||
card.style.flexDirection = FlexDirection.Row;
|
||||
card.style.flexWrap = Wrap.Wrap;
|
||||
card.style.paddingLeft = 12;
|
||||
card.style.paddingRight = 12;
|
||||
card.style.paddingTop = 8;
|
||||
card.style.paddingBottom = 8;
|
||||
card.style.marginBottom = 4;
|
||||
card.style.backgroundColor = new StyleColor(new Color(0.5f, 0.5f, 0.5f, 0.08f));
|
||||
card.style.borderBottomWidth = 1;
|
||||
card.style.borderBottomColor = new StyleColor(new Color(0.5f, 0.5f, 0.5f, 0.2f));
|
||||
|
||||
AddStatChip(card, "类型", w.weaponType.ToString());
|
||||
AddStatChip(card, "地面段数", (w.groundComboSteps?.Length ?? 0).ToString());
|
||||
AddStatChip(card, "空中段数", (w.airComboSteps?.Length ?? 0).ToString());
|
||||
AddStatChip(card, "ID", string.IsNullOrEmpty(w.weaponId) ? "-" : w.weaponId);
|
||||
var card = SkillModule.MakeCard();
|
||||
SkillModule.AddChip(card, "类型", w.weaponType.ToString());
|
||||
SkillModule.AddChip(card, "地面段数", (w.groundComboSteps?.Length ?? 0).ToString());
|
||||
SkillModule.AddChip(card, "空中段数", (w.airComboSteps?.Length ?? 0).ToString());
|
||||
SkillModule.AddChip(card, "ID", string.IsNullOrEmpty(w.weaponId) ? "-" : w.weaponId);
|
||||
return card;
|
||||
}
|
||||
|
||||
private static void AddStatChip(VisualElement parent, string label, string value)
|
||||
{
|
||||
var chip = new VisualElement();
|
||||
chip.style.flexDirection = FlexDirection.Row;
|
||||
chip.style.alignItems = Align.Center;
|
||||
chip.style.marginRight = 14;
|
||||
chip.style.marginBottom = 2;
|
||||
|
||||
var lbl = new Label(label + ":");
|
||||
lbl.style.opacity = 0.6f;
|
||||
lbl.style.fontSize = 11;
|
||||
lbl.style.marginRight = 3;
|
||||
chip.Add(lbl);
|
||||
|
||||
var val = new Label(value);
|
||||
val.style.fontSize = 11;
|
||||
val.style.unityFontStyleAndWeight = UnityEngine.FontStyle.Bold;
|
||||
chip.Add(val);
|
||||
|
||||
parent.Add(chip);
|
||||
}
|
||||
|
||||
private VisualElement BuildActionBar(WeaponSO w)
|
||||
{
|
||||
var bar = new VisualElement();
|
||||
bar.style.flexDirection = FlexDirection.Row;
|
||||
bar.style.paddingLeft = 12;
|
||||
bar.style.paddingRight = 12;
|
||||
bar.style.paddingTop = 6;
|
||||
bar.style.paddingBottom = 6;
|
||||
bar.style.flexWrap = Wrap.Wrap;
|
||||
|
||||
var btnPing = new Button(() => { EditorGUIUtility.PingObject(w); Selection.activeObject = w; })
|
||||
{ text = "在 Project 中定位", tooltip = "在 Project 窗口高亮此资产" };
|
||||
bar.Add(btnPing);
|
||||
|
||||
var btnClone = new Button(() =>
|
||||
{
|
||||
var clone = AssetOperations.Clone(w, Folder);
|
||||
if (clone != null) _listPane.Refresh(clone);
|
||||
}) { text = "克隆..." };
|
||||
bar.Add(btnClone);
|
||||
|
||||
var btnDel = new Button(() =>
|
||||
{
|
||||
if (AssetOperations.Delete(w)) _listPane.Refresh(null);
|
||||
}) { text = "删除" };
|
||||
btnDel.style.borderLeftColor = new StyleColor(new Color(0.8f, 0.3f, 0.3f, 0.6f));
|
||||
btnDel.style.borderRightColor = new StyleColor(new Color(0.8f, 0.3f, 0.3f, 0.6f));
|
||||
btnDel.style.borderTopColor = new StyleColor(new Color(0.8f, 0.3f, 0.3f, 0.6f));
|
||||
btnDel.style.borderBottomColor = new StyleColor(new Color(0.8f, 0.3f, 0.3f, 0.6f));
|
||||
btnDel.style.borderLeftWidth = 1;
|
||||
btnDel.style.borderRightWidth = 1;
|
||||
btnDel.style.borderTopWidth = 1;
|
||||
btnDel.style.borderBottomWidth = 1;
|
||||
btnDel.style.marginLeft = 8;
|
||||
bar.Add(btnDel);
|
||||
|
||||
return bar;
|
||||
}
|
||||
|
||||
private static VisualElement MakeDivider()
|
||||
{
|
||||
var d = new VisualElement();
|
||||
d.style.height = 1;
|
||||
d.style.backgroundColor = new StyleColor(new Color(0.5f, 0.5f, 0.5f, 0.2f));
|
||||
return d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user