Search Unity

I need help with the code, please.

Discussion in 'Scripting' started by NickCikovic, Aug 19, 2017.

  1. NickCikovic

    NickCikovic

    Joined:
    Aug 19, 2017
    Posts:
    28
    Untitled.png Untitled2.png
    I have no idea what to do here. I will be extremely grateful if anyone can figure this out.
     
  2. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    Line 38 - add '}' at end of line.

    Lines 50 & 54 have different capitalisation. Consider using '_colorComponent' for the private version for clarity and to avoid the name conflict with line 52.
     
  3. NickCikovic

    NickCikovic

    Joined:
    Aug 19, 2017
    Posts:
    28
    the error for Lines 50 and 54 worked. Thanks. But, I ran into another issue. Untitled.png
     
  4. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    The error messages in red tell you what to look for. It's generally best to fix the earliest one first, so find out why ')' is unexpected on line 71 and work on that.
     
  5. NickCikovic

    NickCikovic

    Joined:
    Aug 19, 2017
    Posts:
    28
    I don't mean to sound desperate, I've been trying for 20 minutes. I can't figure out what to do.
     
  6. lordconstant

    lordconstant

    Joined:
    Jul 4, 2013
    Posts:
    389
    Line 71 you have a ) when you meant to put (.
     
    NickCikovic likes this.
  7. DominoM

    DominoM

    Joined:
    Nov 24, 2016
    Posts:
    460
    '(' and ')' come in pairs, so do '{' and '}'. Find what needs changing so you have equal amounts of both opening and closing versions.
     
  8. NickCikovic

    NickCikovic

    Joined:
    Aug 19, 2017
    Posts:
    28
    I tried that on all the )'s.
     
  9. NickCikovic

    NickCikovic

    Joined:
    Aug 19, 2017
    Posts:
    28
    I will try that. I'm still very new at c# coding.
     
  10. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Unexpected symbol almost always means something immediately before the symbol was wrong. In this case it's a bracket the wrong direction.
     
    NickCikovic and TaleOf4Gamers like this.
  11. dpgdemos

    dpgdemos

    Joined:
    Apr 28, 2014
    Posts:
    24
    If you are still struggling, your errors lie within line 71 of your script image.
    Like @DominoM mentioned, generally you want to pay close attention to the top-most errors and definitely look for matching pairs of parentheses, brackets, and curly braces.
     
    NickCikovic likes this.
  12. NickCikovic

    NickCikovic

    Joined:
    Aug 19, 2017
    Posts:
    28
    Thanks, I figured most of them out, but I got one more to figure out if you don't mind. This: Untitled.png
     
  13. lordconstant

    lordconstant

    Joined:
    Jul 4, 2013
    Posts:
    389
    This is yours:
    ContainsKey)newColor))

    This is the fixed version:
    ContainsKey(newColor))

    Brackets and braces always contain something so they are paired around () {}.
     
  14. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You really should be using code tags.

    The correct line is:

    Code (CSharp):
    1. if(colorSpriteDict.ContainsKey(newColor)){
    Note the direction of the brackets.