12345678910111213141516171819202122232425262728 |
- using UnityEngine;
- using System.Linq;
- using System.Collections;
- using System.Collections.Generic;
- public static class ExtensionDictionary
- {
- public static T2 Random<T1, T2>(this Dictionary<T1, T2> dic)
- {
- return dic.Values.ToList().Random();
- }
- public static bool UniqueAdd<T1, T2>(this Dictionary<T1, T2> dic, T1 t1, T2 t2)
- {
- if (dic.ContainsKey(t1))
- {
- return false;
- }
- else
- {
- dic.Add(t1, t2);
- return true;
- }
- }
- }
|