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

error CS1525

Discussion in 'Scripting' started by ThreeCents, Aug 8, 2018.

  1. ThreeCents

    ThreeCents

    Joined:
    Jul 12, 2018
    Posts:
    32
    I got an error but I can't find it. I searched on google, tried to understand but, I can't !

    Assets/GameManager.cs(51,248): error CS1525: Unexpected symbol `end-of-file'

    Here's the code :

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class GameManager : MonoBehaviour {
    6.  
    7.     public static int PlayerScore1 = 0;
    8.     public static int PlayerScore2 = 0;
    9.  
    10.     public GUISkin layout;
    11.  
    12.     GameObject theBall;
    13.  
    14.     void Start () {
    15.     theBall = GameObject.FindGameObjectWithTag("Ball");
    16. }
    17.  
    18. public static void Score (string wallID) {
    19.     if (wallID == "RightWall")
    20.     {
    21.         PlayerScore1++;
    22.     } else
    23.     {
    24.         PlayerScore2++;
    25.     }
    26. }
    27.  
    28. void OnGUI () {
    29.     GUI.skin = layout;
    30.     GUI.Label(new Rect(Screen.width / 2 - 150 - 12, 20, 100, 100), "" + PlayerScore1);
    31.     GUI.Label(new Rect(Screen.width / 2 + 150 + 12, 20, 100, 100), "" + PlayerScore2);
    32.  
    33.     if (GUI.Button(new Rect(Screen.width / 2 - 60, 35, 120, 53), "RESTART"))
    34.     {
    35.         PlayerScore1 = 0;
    36.         PlayerScore2 = 0;
    37.         theBall.SendMessage("RestartGame", 0.5f, SendMessageOptions.RequireReceiver);
    38.     }
    39.  
    40.     if (PlayerScore1 == 10)
    41.     {
    42.         GUI.Label(new Rect(Screen.width / 2 - 150, 200, 2000, 1000), "PLAYER ONE WINS");
    43.         theBall.SendMessage("ResetBall", null, SendMessageOptions.RequireReceiver);
    44.     } else if (PlayerScore2 == 10)
    45.     {
    46.         GUI.Label(new Rect(Screen.width / 2 - 150, 200, 2000, 1000), "PLAYER TWO WINS");
    47.         theBall.SendMessage("ResetBall", null, SendMessageOptions.RequireReceiver);
    48.     }
    49. }
    50.  
     
  2. LiterallyJeff

    LiterallyJeff

    Joined:
    Jan 21, 2015
    Posts:
    2,802
    Count your opening curly braces, and make sure you have just as many closing curly braces.

    It's probably reaching the end of the file before it reaches the end of your class. Hence the "unexpected end of file".

    Just a tip: for beginners it's really nice to always put your opening curly brace on the next line, that way you can visually line up the matching closing brace. Right now you have a mix.
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I don't see a closing curly brace for the GameManager class. So the error is literally what it says. It unexpectedly hit the end of the file when there should have been more to it.
     
  4. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,151
    Also Visual Studios 2017 should have a dotted line that connects opening and closing brackets. (may be available in other versions as well)
     
  5. ThreeCents

    ThreeCents

    Joined:
    Jul 12, 2018
    Posts:
    32
    Okay thanks !