62 lines
No EOL
2.1 KiB
C#
62 lines
No EOL
2.1 KiB
C#
// 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 CurrencyType’a 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;
|
||
}
|
||
}
|
||
} |