Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

StartCoroutine(loadlevel());

Discussion in 'Scripting' started by brano42, Aug 25, 2020.

  1. brano42

    brano42

    Joined:
    Aug 25, 2020
    Posts:
    77
    Hello help me pls here is error cannot convert from 'System.Collections.IEnumerable' to 'string'

    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class LoadLevel : MonoBehaviour
    7. {
    8.     public string level;
    9.  
    10.     void OnTriggerStay(Collider target)
    11.     {
    12.         if (target.tag == "Player")
    13.         {
    14.  
    15.            StartCoroutine(loadlevel());
    16.  
    17.         }
    18.     }
    19.  
    20.     IEnumerable loadlevel()
    21.     {
    22.  
    23.         yield return new WaitForSeconds(5);
    24.         Application.LoadLevel(level);
    25.     }
    26.  
    27.  
    28. }
    29.  
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,587
  3. mopthrow

    mopthrow

    Joined:
    May 8, 2020
    Posts:
    341
    Line 20, IEnumerator not IEnumerable :)
     
    PraetorBlue likes this.
  4. brano42

    brano42

    Joined:
    Aug 25, 2020
    Posts:
    77
    thanks man very much :D