I’m coding in C# and I have a problem. It is a quite big project in Unity and we have a lot of .cs-scripts. Now I have found a problem.
I have a script that runs in the beginning of the application in one of the .cs scripts, in a Awake() and in this Awake() call I do a www post in a StartCoroutine(TheWWWCallToFillAHashTable);
Ok, from here it is easy. But now it seems like this hashtable does not have time to be filled, because I need to call this hashtable from another class in game and then it is empty.
So my question is: Is there any way to be certain that this function has ended before other scripts starts? I have tried with different things (script priority order) but it takes to long time to fill the hashtable so all other scripts have time to start.
Or check whether or not the Hashtable has any values. The better solution is probably to design some kind of loading screen to prevent user interaction while the Hashtable is being populated.
Another option is to add a callback in your TheWWWCallToFillAHashTable that will let you know when it’s finished…
public delegate void FinishedHandler();
public event FinishedHandler Finished;
private void TheWWWCallToFillAHashTable()
{
// do your calls here, fill the hash table
if (this.Finished != null)
{
this.Finished();
}
}