private void OnTriggerEnter2D(Collider2D collision) { GameObject collisionGameObject = collision.gameObject; if (collisionGameObject.name == "Player") { fading.fadeOut(); StartCoroutine(ExecuteAfterTime(1)); IEnumerator ExecuteAfterTime(float time) { yield return(new WaitForSeconds(time)); // Code to execute after the delay LoadScene(); } } }