I have the below structure of code, where Coroutine2 calls Coroutine1, wait for its finish and do some other things.
In Coroutine1, I call a web service and this is where I stuck. I need to call this Coroutine1 continuously (every second) to check if there is an update on the fetched data on the web service.
I tried the possible solutions on forums but they are not calling a web service or calling a corouitne from another coroutine. So I could not achive those solutions.
I haven’t tried calling a coroutine from a coroutine, but calling something once a second is pretty trivial to do just from update anyway. That way you’d eliminate the calling a coroutine from another coroutine as part of whatever problem you’re having.
private float nextTimeCall;
void Start()
{
nextTimeCall = Time.time + 1f;
}
void Update()
{
if (Time.time >= nextTimeCall)
{
doSomething();
nextTimeCall += 1f;
}
}
void doSomething()
{
//whatever you want to do once a second here
}