UI系统优化
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 472cbbc6ac2cacd46947af5235b8e47b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
56
Assets/_Game/Scripts/Editor/Shared/DataHubEditorKit.cs
Normal file
56
Assets/_Game/Scripts/Editor/Shared/DataHubEditorKit.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace BaseGames.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// DataHub 模块通用 UI 工具集。提供跨模块复用的 UIElements 控件工厂方法。
|
||||
/// </summary>
|
||||
public static class DataHubEditorKit
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建可切换的过滤标签按钮(圆角 chip 样式)。
|
||||
/// 点击后切换激活/非激活状态,并触发 <paramref name="onToggle"/> 回调。
|
||||
/// </summary>
|
||||
public static VisualElement MakeFilterChip(string label, Action<bool> onToggle)
|
||||
{
|
||||
bool active = false;
|
||||
var chip = new Label(label);
|
||||
chip.style.fontSize = 10;
|
||||
chip.style.paddingLeft = 6;
|
||||
chip.style.paddingRight = 6;
|
||||
chip.style.paddingTop = 2;
|
||||
chip.style.paddingBottom = 2;
|
||||
chip.style.marginRight = 4;
|
||||
chip.style.marginBottom = 2;
|
||||
chip.style.borderTopLeftRadius = 8;
|
||||
chip.style.borderTopRightRadius = 8;
|
||||
chip.style.borderBottomLeftRadius = 8;
|
||||
chip.style.borderBottomRightRadius = 8;
|
||||
chip.style.borderTopWidth = 1;
|
||||
chip.style.borderRightWidth = 1;
|
||||
chip.style.borderBottomWidth = 1;
|
||||
chip.style.borderLeftWidth = 1;
|
||||
var borderColor = new StyleColor(new Color(0.5f, 0.5f, 0.5f, 0.4f));
|
||||
chip.style.borderTopColor = borderColor;
|
||||
chip.style.borderRightColor = borderColor;
|
||||
chip.style.borderBottomColor = borderColor;
|
||||
chip.style.borderLeftColor = borderColor;
|
||||
chip.style.opacity = 0.6f;
|
||||
|
||||
void SetActive(bool on)
|
||||
{
|
||||
active = on;
|
||||
chip.style.opacity = on ? 1f : 0.6f;
|
||||
chip.style.backgroundColor = on
|
||||
? new StyleColor(new Color(0.3f, 0.6f, 1f, 0.25f))
|
||||
: StyleKeyword.None;
|
||||
onToggle(on);
|
||||
}
|
||||
|
||||
chip.RegisterCallback<ClickEvent>(_ => SetActive(!active));
|
||||
return chip;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/_Game/Scripts/Editor/Shared/DataHubEditorKit.cs.meta
Normal file
11
Assets/_Game/Scripts/Editor/Shared/DataHubEditorKit.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 666eee8c08676294db8404d0eb3409f2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -247,7 +247,6 @@ namespace BaseGames.Editor
|
||||
if (_extraFilter != null && !_extraFilter(item)) continue;
|
||||
_filtered.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
_listView.RefreshItems();
|
||||
_countLabel.text = _all.Count == _filtered.Count
|
||||
|
||||
Reference in New Issue
Block a user