예제 #1
0
    public void Despawn(GameObject obj)
    {
        IDestroySelf destructibleObject = obj.GetComponent <IDestroySelf>();

        if (destructibleObject != null)
        {
            destructibleObject.DestroySelf();
        }
    }
예제 #2
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Enemy")
     {
         IDestroySelf destructibleEnemy = other.GetComponent <IDestroySelf>();
         if (destructibleEnemy != null)
         {
             destructibleEnemy.DestroySelf();
         }
     }
 }