Playvoi/Playvoi.Client/Assets/ShiroginSDK/Runtime/Modules/Data/Scripts/Icons/CurrencyIconLibrary.cs

62 lines
No EOL
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Assets/ShiroginSDK/Runtime/Data/Icons/CurrencyIconLibrary.cs
using System;
using System.Collections.Generic;
using ShiroginSDK.Runtime.Modules.Data.Scripts.Enums;
using UnityEngine;
namespace ShiroginSDK.Runtime.Modules.Data.Scripts.Icons
{
/// <summary>
/// Her CurrencyType için karşılık gelen ikonları depolar.
/// Bu sınıf doğrudan SDK.Config.currencyIconLibrary üzerinden erişilmelidir.
/// </summary>
[CreateAssetMenu(fileName = "CurrencyIconLibrary", menuName = "ShiroginSDK/Data/Currency Icon Library", order = 10)]
public class CurrencyIconLibrary : ScriptableObject
{
[Header("Currency Icon Listesi")] [Tooltip("Her para birimi için kullanılacak ikonları belirle.")]
public List<CurrencyIconEntry> icons = new();
/// <summary>
/// Belirtilen CurrencyTypea karşılık gelen ikonu döndürür.
/// Eğer bulunamazsa null döner.
/// </summary>
public Sprite GetIcon(CurrencyType type)
{
if (type == CurrencyType.None)
return null;
foreach (var entry in icons)
if (entry.type == type)
return entry.icon;
return null;
}
#if UNITY_EDITOR
/// <summary>
/// Editor araçları için kolay erişim (örneğin otomatik doldurma).
/// </summary>
[ContextMenu("Auto Fill Missing Entries")]
private void AutoFillMissingEntries()
{
var types = Enum.GetValues(typeof(CurrencyType));
foreach (CurrencyType t in types)
{
if (t == CurrencyType.None) continue;
var exists = icons.Exists(e => e.type == t);
if (!exists)
icons.Add(new CurrencyIconEntry { type = t, icon = null });
}
Debug.Log("[CurrencyIconLibrary] Missing entries added automatically.");
}
#endif
[Serializable]
public struct CurrencyIconEntry
{
public CurrencyType type;
public Sprite icon;
}
}
}