Files
back_cantanBuilding/Assets/Scripts/UI/Albun/AlbumAttribute.cs
2026-05-26 16:15:54 +08:00

70 lines
2.2 KiB
C#

using asap.core;
using cfg;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class AlbumAttribute : MonoBehaviour
{
public static string[] AlbumBg =
{
"bg_album_album_white",
"bg_album_album_blue",
"bg_album_album_purple",
"bg_album_album_yellow",
};
public static string[] sp_album_card_title =
{
"sp_album_card_title_white",
"sp_album_card_title_blue",
"sp_album_card_title_purple",
"sp_album_card_title_yellow",
"sp_album_card_title_yellow",
};
public Image bg_album;
public Image icon;
public Image bg_title;
public TMP_Text[] text_names;
public Image bar;
public TMP_Text text_progress;
public Album data;
#if UNITY_EDITOR
private void Reset()
{
if (icon == null)
{
bg_album = transform.Find("bg_album").GetComponent<Image>();
icon = transform.Find("icon_album").GetComponent<Image>();
bg_title = transform.Find("bg_title").GetComponent<Image>();
// text_name = transform.Find("text_name_yellow").GetComponent<TMP_Text>();
bar = transform.Find("bg_bar/bar").GetComponent<Image>();
text_progress = transform.Find("bg_bar/bar/text_progress").GetComponent<TMP_Text>();
}
}
#endif
public void Init(Album _data)
{
data = _data;
GContext.container.Resolve<IUIService>().SetImageSprite(bg_album, AlbumBg[data.Quality - 1], BasePanel.PanelName);
GContext.container.Resolve<IUIService>().SetImageSprite(icon, data.Image, BasePanel.PanelName);
GContext.container.Resolve<IUIService>().SetImageSprite(bg_title, sp_album_card_title[data.Quality - 1], BasePanel.PanelName);
for (int i = 0; i < text_names.Length; i++)
{
text_names[i].gameObject.SetActive(i == data.Quality - 1);
if (data.Quality - 1 == i)
{
text_names[i].text = LocalizationMgr.GetText(data.Title_l10n_key);
}
}
if (data.Quality > text_names.Length)
{
text_names[^1].text = LocalizationMgr.GetText(data.Title_l10n_key);
text_names[^1].gameObject.SetActive(true);
}
}
}