36 lines
1.4 KiB
C#
36 lines
1.4 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using BaseGames.Localization;
|
|
|
|
namespace BaseGames.UI
|
|
{
|
|
/// <summary>
|
|
/// 能力总览单元格视图:图标 + 名称 + 已解锁/未解锁视觉(未解锁时暗化 + 显示锁定遮罩)。
|
|
/// 由 <see cref="DataDrivenAbilityPanel"/> 据 AbilityMetaSO 实例化并 Bind。
|
|
/// </summary>
|
|
[DisallowMultipleComponent]
|
|
public class AbilityCellView : MonoBehaviour
|
|
{
|
|
[SerializeField] private Image _icon;
|
|
[SerializeField] private LocalizedText _label;
|
|
[Tooltip("未解锁时显示(锁图标 / 暗罩,可空)。")]
|
|
[SerializeField] private GameObject _lockedOverlay;
|
|
[Tooltip("整格暗化用(可空)。")]
|
|
[SerializeField] private CanvasGroup _group;
|
|
|
|
public void Bind(string labelKey, Sprite icon, bool unlocked)
|
|
{
|
|
if (_label != null) _label.SetKey(labelKey);
|
|
if (_icon != null) { _icon.sprite = icon; _icon.enabled = icon != null; }
|
|
SetUnlocked(unlocked);
|
|
}
|
|
|
|
/// <summary>只更新解锁态(保留图标/名称)。设备/解锁事件刷新时调用。</summary>
|
|
public void SetUnlocked(bool unlocked)
|
|
{
|
|
if (_lockedOverlay != null) _lockedOverlay.SetActive(!unlocked);
|
|
if (_group != null) _group.alpha = unlocked ? 1f : 0.4f;
|
|
}
|
|
}
|
|
}
|