Skip to main content
1 of 3
Zibelas
  • 5k
  • 2
  • 15
  • 26

This can be easily solved by your first bullet point. Just implement the override. You will need to come up with a way to identify NeemData List on your own since I do not know the structure of it. It might be as easy as just taking the length of the array (might not be 100% unique but that would mean you first need to have the same soundname with the same amount of sound clips).

[Serializable]
public class BlendKey {
    [SerializeField]
    public string soundName;
    [SerializeField]
    public List<String> neemList;

    public override bool Equals(object obj) {
        if (obj == null)
            return false;
        BlendKey c = obj as BlendKey ;
        if ((System.Object)c == null)
            return false;
        return soundName.Equals(c.soundName);
   }

    public override int GetHashCode() {
        return soundName.GetHashCode();
    }
}


public class TestDic: MonoBehaviour {
    
    public Dictionary<BlendKey, string> testDic = new Dictionary<BlendKey, string>();
    
    private void Start() {
        BlendKey testKey = new BlendKey();
        testKey.soundName = "ABC";
        testKey.neemList = new List<string>{"1", "2"};
        testDic.Add(testKey, "Sound 1");
        
        BlendKey testKey2 = new BlendKey();
        testKey2.soundName = "XYZ";
        testKey2.neemList = new List<string>{"8", "9"};
        testDic.Add(testKey2, "Sound 2");

        BlendKey testKey3 = new BlendKey();
        testKey3.soundName = "ABC";
        testKey3.neemList = new List<string>{"1", "2"};
        
        Debug.Log(testDic[testKey]);
        Debug.Log(testDic[testKey2]);
        Debug.Log(testDic[testKey3]);
    }
}
Zibelas
  • 5k
  • 2
  • 15
  • 26