Search Unity

Having issues with StartCoroutine

Discussion in 'Scripting' started by Huwey, Mar 17, 2019.

  1. Huwey

    Huwey

    Joined:
    Mar 17, 2019
    Posts:
    29
    Hello, to start off I want to say that I am very new to all of this and was working my way through a tutorial on youtube when I noticed that I was getting an error that the person doing the video didn't get.

    Can someone help me with the issue?

    Here is what I have:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class SplashtoMenu : MonoBehaviour
    7. {
    8.     void Start()
    9.     {
    10.         StartCoroutine(LoadMenu());
    11.     }
    12.  
    13.     IEnumerable LoadMenu()
    14.     {
    15.         yield return new WaitForSeconds(4);
    16.         SceneManager.LoadScene(1);
    17.     }
    18. }
    19.  
    This is the error message that I'm getting:

    SplashtoMenu.cs(10,24): error CS1503: Argument 1: cannot convert from 'System.Collections.IEnumerable' to 'string'

    I am using Unity 2018.3.8f1 personal and Visual Studio v. 4.7.03056 in case that makes a difference.
     
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,035
    IEnumerator not IEnumerable
     
    JacobMHulse likes this.
  3. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,317
    The method should return IEnumerator, not IEnumerable.
     
  4. Huwey

    Huwey

    Joined:
    Mar 17, 2019
    Posts:
    29
    Thank you! I didn't notice that.