Files
test/Assets/PerfectWorld/Scripts/UI/GamePlay/SkillUI/Widget/SkillSlotWidget.cs
T
2026-04-08 17:35:01 +07:00

52 lines
1.3 KiB
C#

using System;
using BrewMonster.Assets.PerfectWorld.Scripts.UI.GamePlay;
using UnityEngine;
using UnityEngine.UI;
namespace BrewMonster
{
public enum SkillSlotType
{
Normal= 0,
AddSkill
}
public class SkillSlotWidget : AUIImagePictureBase
{
[SerializeField] private SkillSlotType _skillSlotType;
[SerializeField] private Image _backgroundImage;
[SerializeField] private Button _button;
[SerializeField] private Sprite[] _slotBackgrounds;
public event Action<SkillSlotWidget> OnClickedSkillSlot;
private void OnValidate()
{
var index = (int)_skillSlotType;
if (index < 0 || index >= _slotBackgrounds.Length)
{
BMLogger.LogError("Invalid skill slot type");
}
else
{
if(_backgroundImage == null) return;
_backgroundImage.sprite = _slotBackgrounds[index];
}
}
private void OnEnable()
{
_button.onClick.AddListener(OnClickedButton);
}
private void OnDisable()
{
_button.onClick.RemoveListener(OnClickedButton);
}
private void OnClickedButton()
{
OnClickedSkillSlot?.Invoke(this);
}
}
}