// don`t allow to user to add a word if that word exists already // verify if inputs contains words and definition and after add the element in dictionary and save it, when Add button is pressed // after adding word, cleared input field public void AddWord() { var space = ""; if (!myDictionary.MyDictionary.Keys.Contains(key.text)) { consoleText.text = ""; if ((!string.IsNullOrEmpty(key.text) || !key.text.Contains(space)) && (!string.IsNullOrEmpty(valueDef.text) || !valueDef.text.Contains(space))) { myDictionary.AddElement(key.text, valueDef.text); ShowWords(); myDictionary.Save(); Debug.Log(key.text + " -- " + valueDef.text); ClearFields(); consoleText.text = "Word successfully added"; } else { consoleText.text = "Insert a word or definition!"; Debug.Log("Insert a word or definition!"); } } else { consoleText.text = "Element already exist!"; Debug.Log("Element already exist!"); } }