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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

error CS1519: Unexpected symbol `Start' in class, struct, or interface member declaration

Discussion in 'Getting Started' started by PokemonX2013, May 25, 2015.

  1. PokemonX2013

    PokemonX2013

    Joined:
    May 25, 2015
    Posts:
    3
    Sorry for being such a noob and all but,
    What's wrong with this?

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class SplashScreenloadintro1 : MonoBehaviour {
    5.     public float delayTime = 5;
    6.  
    7.      StartCoroutine ("Start");
    8.  
    9. }
    10.      IEnumerator Start(){
    11.         float fadeTime = GameObject.Find("Credits_0").GetComponent<Fade>().BeginFade(1)
    12.         yield return new WaitForSeconds(fadeTime);
    13.         Application.LoadLevel(Application.LoadLevel + 1);
    14.  
    15.  
    16.     }
    17.   }

    P.S. I'm new to programming and Unity. You must have figured that out by now.
     
  2. SomeJDude

    SomeJDude

    Joined:
    Feb 13, 2015
    Posts:
    10
    You've got your braces mixed up. On line 9 you have a closing brace, and on line 17 you have an extra closing brace. Delete the one on line 9 and you should be good.
     
  3. PokemonX2013

    PokemonX2013

    Joined:
    May 25, 2015
    Posts:
    3
    that gives an error that yield is an unexpected symbol.
     
  4. NomadKing

    NomadKing

    Joined:
    Feb 11, 2010
    Posts:
    1,461
    I'm not sure what you're trying to do, but you're using a function call (StartCoroutine) in the middle of a class definition (SplashScreenloadintro1). On top of that, you're missing a semicolon on line 11, should probably be using 'loadedLevel + 1' on line 13, and shouldn't use Start as a function name for your enumerator.

    Your code should look more like this:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class SplashScreenloadintro1 : MonoBehaviour {
    5.     public float delayTime = 5;
    6.  
    7.     void Start() {
    8.         StartCoroutine ("StartMe");
    9.     }
    10.  
    11.     IEnumerator StartMe(){
    12.         float fadeTime = GameObject.Find("Credits_0").GetComponent<Fade>().BeginFade(1);
    13.         yield return new WaitForSeconds(fadeTime);
    14.         Application.LoadLevel(Application.loadedLevel + 1);
    15.     }
    16. }
     
    Last edited: May 27, 2015
    jhocking and PokemonX2013 like this.
  5. PokemonX2013

    PokemonX2013

    Joined:
    May 25, 2015
    Posts:
    3
    Oh, right, now I understood. Thanks for clearing that up. This is gonna be tough...
     
    NomadKing likes this.