title: How can I continue Coroutine after calling it from a script that I deactivated after that call
body: <p>I have a Coroutine in  a class <code>Enamy</code> that is attached to a gameobject. Now I am using a <code>Projectile</code> to hit that enemy and disable both of them. The problem is that I don't want to deactivate the projectile in the same time as the enemy. The enemy has some special effects that need to be executed before disable.</p>
  
  <p>To solve this problem I come up with this: </p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class Enamy : MonoBehaviour {
  
      public IEnumerator DestroyEnamy()
      {
          yield return new WaitForSeconds(1f);
          Debug.Log("Execute after 1 second");
          gameObject.SetActive(false);
      }
  }
  </code></pre>
  
  <p>I want to call the <code>DestroyEnamy</code> coroutine in the Projectile class than deactivate the <code>Projectile</code> class while still continuing the <code>DestroyEnamy</code> coroutine. However that is not happening, the coroutine is executed only if I keep the <code>Projectile</code> class enabeled, if I disable before the ending of the coroutine it executes the first part of the coroutine then after the "Projectile" gameObject is disabeled the coroutine stops as well.</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  
  public class Projectile : MonoBehaviour
  {
  
      private bool firstCollision = false;
  
      private void OnEnable()
      {
          firstCollision = false;
      }
      private void OnCollisionEnter2D(Collision2D collision)
      {
          if (!firstCollision)
          {
              //if the projectile has landed a hit
              firstCollision = true;
  
              Transform colliderTransform = collision.transform;
  
              if (colliderTransform.CompareTag("Enamy")) 
              {
                  Score.UpdateMainScore(20);
                  Score.UpdateProjCount(1);
                  colliderTransform.gameObject.SetActive(false);
              }
              gameObject.SetActive(false);
          }
      }
  }
  </code></pre>