[Serializable]
public class BlendKey {
[SerializeField]
public string soundName;
[SerializeField]
public List<String>List<NeemData> neemList;
public override bool Equals(object obj) {
if (obj == null)
return false;
BlendKey c = obj as BlendKey ;
if (c == null)
return false;
if (!soundName.Equals(c.soundName)) return false;
if (neemList.Count != c.neemList.Count) return soundNamefalse;
for (int index = 0; index < neemList.Count; index++) {
if (!neemList[index].neemName.Equals(c.soundNameneemList[index].neemName);) return false;
}
return true;
}
public override int GetHashCode() {
int listHash = 0;
for (int index = 0; index < neemList.Count; index++) {
listHash += neemList[index].neemName.GetHashCode();
}
return soundName.GetHashCode(); + listHash;
}
}
public class TestDic: MonoBehaviour {
public Dictionary<BlendKey, string> testDic = new Dictionary<BlendKey, string>();
public NeemData[] NeemDatas;
private void Start() {
BlendKey testKey = new BlendKey();
testKey.soundName = "ABC";
testKey.neemList = new List<string>List<NeemData>{"1"NeemDatas[0], "2"NeemDatas[1]};
testDic.Add(testKey, "Sound 1");
BlendKey testKey2 = new BlendKey();
testKey2.soundName = "XYZ";
testKey2.neemList = new List<string>List<NeemData>{"8"NeemDatas[1], "9"NeemDatas[2]};
testDic.Add(testKey2, "Sound 2");
BlendKey testKey3 = new BlendKey();
testKey3.soundName = "ABC";
testKey3.neemList = new List<string>List<NeemData>{"1"NeemDatas[1], "2"NeemDatas[0]};
Debug.Log(testDic[testKey]);
Debug.Log(testDic[testKey2]);
Debug.Log(testDic[testKey3]);
}
}
The third testDic[testKey3]); will give you a key not found error since it is not the same data as from testKey (it has the same NeemData, but the order is different). You could solve this by further adding everything for a sort interface but if that is really needed will depends on if the NeemData is generated dynamically or by hand.