Reputation: 15
On button click I run method Initialize()
.
private IEnumerator Initialize()
{
Download download;
download = new Download();
StartCoroutine(download.LoadAsset("http://localhost/3dobjects?key=11","car13",(x)=>{j = x;}));
yield return j;
int k=download.GetRate(j)
}
Second one (GetRate
) depends on result from first method (LoadAsset
), so it should run after LoadAsset
finishes working.
But they run synchronously like in different thread, how to solve it?
Upvotes: 0
Views: 228
Reputation: 1950
I think you want to
yield return StartCoroutine( ...
otherwise you won't be waiting for the coroutine to end.
Upvotes: 1