123456789101112131415161718192021222324252627 |
- using UnityEngine;
- using System.Collections.Generic;
- public static class DictionaryExtensions
- {
- /// <summary>
- /// When DEBUG compiler directive is enabled, we will have more meaningful logs if the key doesn't exist
- /// </summary>
- public static L GetValueForKey<T, L>(
- this Dictionary<T,L> dict, T key)
- {
- #if DEBUG
- if (dict.ContainsKey(key))
- {
- return dict[key];
- } else
- {
- AVDebug.LogError("Key "+key+ " was not found in dictionary");
- return default(L);
- }
- #else
- return dict[key];
- #endif
- }
- }
|