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

Help My code spits out multiple errors and warnings

Discussion in 'Scripting' started by Jacazza, Aug 10, 2017.

  1. Jacazza

    Jacazza

    Joined:
    Aug 10, 2017
    Posts:
    5
    The code I'm working on from a udemy course is not working and I'm getting lots of errors.
    Currently on Lecture 32 if your wondering.
    (Unity Version 4.6.9 if that is important.)
     

    Attached Files:

  2. Bantaru

    Bantaru

    Joined:
    May 11, 2016
    Posts:
    59
    You are missing closing bracket at line 24.

    About the rest have no idea why it is happening. I done same course and never had such problems.
     
  3. LilFire

    LilFire

    Joined:
    Jul 11, 2017
    Posts:
    74
    You forgot a ")" before "{" line 24
     
  4. Jacazza

    Jacazza

    Joined:
    Aug 10, 2017
    Posts:
    5
    Where does the bracket go on line 24 does it go at the start or underneath a certain word.
     
  5. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    Directly after 'Sheets_0' should be a closing parenthesis ')'.

    Just for future reference, always check the line where the first error occurs, all following errors may just be a side effect of the first syntax error.
     
  6. Jacazza

    Jacazza

    Joined:
    Aug 10, 2017
    Posts:
    5
    This fixes nothing and just gives me a different error:
    Error CS1520: Class, struct, or interface method must have a return type
     
  7. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    How dare you!
    We did indeed fix your error. What you are getting is something different and is not our fault.
    Im out.

    EDIT: We need more info if you actually want help. Does it say what script it is?
     
    Last edited: Aug 11, 2017
  8. welpie21

    welpie21

    Joined:
    Dec 23, 2014
    Posts:
    49
    next time copy and paste the code in the "code format" in the toolbar.

    Code (CSharp):
    1. void Update()
    2. {
    3.     print(myState);
    4.  
    5.     if(myState == States.cell)
    6.     {
    7.         state_cell();
    8.     }
    9.     else if(myState == States.sheets_0) // forgot an " ) " at the end.
    10.     {
    11.         state_Sheets_0();
    12.     }  
    13. }
    and here is your fix..
     
  9. welpie21

    welpie21

    Joined:
    Dec 23, 2014
    Posts:
    49
    "at line 9" in the "else if" statement you forgot an " ) "
     
  10. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    Guys, please. Read his message, he has a different error now.

     
  11. welpie21

    welpie21

    Joined:
    Dec 23, 2014
    Posts:
    49
    oh, when i wrote. the message what he posted was not updated.. my bad :)