Something more about CoRoutines

Hello everyone,
I was trying to understand some unexpected behavior about CoRoutines.

The situation is the following:

There are three public gameobject instantiated with the same prefab, this way

go1 = GameObject.Instantiate (prefab);
go2 = GameObject.Instantiate (prefab);
go3 = GameObject.Instantiate (prefab);

Then I call three times a CoRoutine to destroy those gameobjects in three different moments but from the same method, this way

if(cond 1){
    StartCoroutine (WaitTotObj (go1));
    return;
}
if(cond 2){
    StartCoroutine (WaitTotObj (go2));
    return;
}
if(cond 3){
    StartCoroutine (WaitTotObj (go3));
    return;
}

WaitToObj is something like this

public IEnumerator WaitTotObj(UnityEngine.Object obj){
        yield return new WaitForSeconds (((GameObject)obj).GetComponent<ParticleSystem> ().startLifetime+1);
        Destroy (obj);
}

What happens next is that only one of the three gameObject gets destroyed.

Can anyone explain me this behavior and, in the case, just tell me how to solve this problem?

Are your if conditions in any kind of loop, for, foreach ? because “break;” breaks the loop and skips rest of the code under it.

Sorry, They are return commands. I updated main post.
The functions is called to trigger particle effects in different moments, there are no loops in it.

The thing I really can’t explain is that if I change the conditions adding code like this

if(cond 3){
    StartCoroutine (WaitTotObj (go3));
    go3 = null;
    return;
}

all the gameobjects get destroyed correctly. But I can’t understand why.

I forgot to say that condnumber are like

 go*number* != null

What is the MonoBehaviour that is starting the coroutine on? Coroutines will stop executing if the object they are called on is destroyed or set to inactive.

StartCoroutine(WaitTotObj (go1));

What is this? Where do you get a reference to ‘WaitTotObj’?

And please, post the actual script, theres spelling errors, questions and missing code that could be related all over the place in here.

I think I had some response for this problem.
For how was structured my code if I didn’t set the object to null, after calling the coroutine, further calls would have entered the first condition. The effect played anyway because I forgot to uncheck play on awake on the particle systems being instantiated.

I want to thank you so much for your precious time

The WaitToObj function is in the same script. It gets called right away.
My mistake was on the hierarchy conditions, since there wasn’t else if clause to avoid entering the others.

And, sorry, I simplified the code to avoid confusion. Thank you for your time too!