I am making a project with Unity that using RestSharp API's.
I can specify and retrieve language keys and values from the server without any problems, and I can keep these values up to date in a dictionary and listen. As soon as the values arrive, that is, when the dictionary is updated, when I want to send the data to the texts, only the active ones in the hierarchy are updated.
public void SetTexts()
{
var languageTexts = FindObjectsOfType<LanguageKeys>();
foreach (LanguageKeys languageText in languageTexts)
{
languageText.SetTexts();
}
}
When I send the values with these codes, they are written instead of the values without any problems.
It also happens if I want to rerun the SetText() function with the OnEnable function, but when the values are coming from the server, I get an error because the key values in the Dictionary are null.
Is there a function like UnityEvent, Action<> where TextMeshProUGUI text can listen to the values from the dictionary and update itself when the values change? How can I improve the code so that it is a more optimized system?