Pro_Unit

BaseKeyValueData.cs

Jun 4th, 2025
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1. public abstract class BaseKeyValueData<TKey, TValue> : ScriptableObject
  2. {
  3.     [SerializeField] private TValue _default;
  4.     [SerializeField] private List<DataPair<TKey, TValue>> _dataPairs;
  5.  
  6.     public IEnumerable<DataPair<TKey, TValue>> Pairs => _dataPairs;
  7.  
  8.     public TValue GetValue(TKey key)
  9.     {
  10.         foreach ((TKey key1, TValue value) in Pairs)
  11.             if (key1.Equals(key))
  12.                 return value;
  13.         return _default;
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment