78 lines
1.7 KiB
C#
78 lines
1.7 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Michsky.UI.Heat
|
|
{
|
|
public class CreditsMentionItem : MonoBehaviour
|
|
{
|
|
[Header("Resources")]
|
|
[SerializeField]
|
|
private Image iconImage;
|
|
|
|
[SerializeField]
|
|
private TextMeshProUGUI descriptionText;
|
|
|
|
public VerticalLayoutGroup listLayout;
|
|
|
|
[HideInInspector]
|
|
public CreditsPreset preset;
|
|
|
|
[HideInInspector]
|
|
public LocalizedObject localizedObject;
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (localizedObject != null && !string.IsNullOrEmpty(localizedObject.localizationKey))
|
|
{
|
|
SetDescription(localizedObject.GetKeyOutput(localizedObject.localizationKey));
|
|
}
|
|
}
|
|
|
|
public void UpdateLayout(int paddingValue, int spacingValue)
|
|
{
|
|
listLayout.padding.top = paddingValue / 2;
|
|
listLayout.padding.bottom = paddingValue / 2;
|
|
listLayout.spacing = spacingValue;
|
|
}
|
|
|
|
public void SetIcon(Sprite icon)
|
|
{
|
|
if (icon == null)
|
|
{
|
|
iconImage.gameObject.SetActive(value: false);
|
|
}
|
|
else
|
|
{
|
|
iconImage.sprite = icon;
|
|
}
|
|
}
|
|
|
|
public void SetDescription(string text)
|
|
{
|
|
if (string.IsNullOrEmpty(text))
|
|
{
|
|
descriptionText.gameObject.SetActive(value: false);
|
|
}
|
|
else
|
|
{
|
|
descriptionText.text = text;
|
|
}
|
|
}
|
|
|
|
public void CheckForLocalization(string key)
|
|
{
|
|
localizedObject = descriptionText.GetComponent<LocalizedObject>();
|
|
if (localizedObject == null || (LocalizationManager.instance != null && !LocalizationManager.instance.UIManagerAsset.enableLocalization))
|
|
{
|
|
localizedObject = null;
|
|
}
|
|
else if (!string.IsNullOrEmpty(key))
|
|
{
|
|
localizedObject.localizationKey = key;
|
|
SetDescription(localizedObject.GetKeyOutput(localizedObject.localizationKey));
|
|
}
|
|
}
|
|
}
|
|
}
|