• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by importguru88 · Aug 14, 2016 at 03:53 AM · scripting problemtimerscript errorunexpected-symbol

/TestScript.cs(26,21): error CS1525: Unexpected symbol `}'

I just doing a repeat in code of what I just did in the if statement to the else statement. I'm trying to get the scene to switch if the score is not reach . I did do an else statement and I keep get this same error /TestScript.cs(26,21): error CS1525: Unexpected symbol `}' . TestScript.cs(37,1): error CS8025: Parsing error

Here is my code :

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 using UnityEngine.SceneManagement;
 
 public class TestScript : MonoBehaviour
 {
     public MyClockScript myClock;
     public ScoreManagerScript scoremanager;
     
     public int scoreToReach = 99;     // change this value to what you want
     public int leastscore = 50;
     public string nextScene = "FY"; // change this value to what you want
 
     void Update () 
     {
           if (myClock.m_leftTime <= 0)
               {
               if ((ScoreManagerScript.score >= scoreToReach) && (nextScene != ""))
                      {
                      SceneManager.LoadScene(nextScene);
                      }
               else
                     {
                  ((ScoreManagerScript.score >= scoreToReach) && (nextScene != ""))
                     }
                }
     }
     
 }
  
     

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Jessespike · Aug 14, 2016 at 04:37 AM

Change ScoreManagerScript to scoremanagerin the if-statement and delete the else-statement.

  void Update() {
     if (myClock.m_leftTime <= 0)
     {
         if ((scoremanager.score >= scoreToReach) && (nextScene != ""))
         {
             SceneManager.LoadScene(nextScene);
         }
     }
 }
Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image importguru88 · Aug 14, 2016 at 08:10 AM 0
Share

That did not work I gotten an error .

avatar image Jessespike · Aug 14, 2016 at 10:04 AM 0
Share

Nah, this is fine and works. You are missing something. At least say what the error is, I'm thinking you copy-pasted and overwrote a curly brace. Double check for any missing or mismatch with the curly braces "{ }", Specifically the one that encapsulates the class.

avatar image Bunny83 · Aug 14, 2016 at 10:11 AM 0
Share

Well, changing Score$$anonymous$$anagerScript to scoremanager might have been the wrong suggestion as it's purely based on assumptions and most likely wrong since the compiler has gone down to that "wrong" line "25" so Score$$anonymous$$anagerScript.score has to compile just fine. "score" is most likely a static variable so he has to use Score$$anonymous$$anagerScript.score.

avatar image Jessespike · Aug 15, 2016 at 02:04 PM 0
Share

That's a good point, score could be static and probably is. In that case OP, use Score$$anonymous$$anagerScript.score ins$$anonymous$$d.

avatar image TBruce · Aug 15, 2016 at 09:52 PM 0
Share

I have already seen Score$$anonymous$$anagerScript.cs and the score property is static so this is not a problem. It is inside the else block where you have this

 ((Score$$anonymous$$anagerScript.score >= scoreToReach) && (nextScene != ""))

that is your problem. Just commenting out the line or deleting the whole else block like @Jessespike mentioned will get rid of the error.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

69 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

What is wrong with the script 1 Answer

Script isn't consistent 0 Answers

Unexpected coroutine behavior for simple timer 2 Answers

Script error 1 Answer

how to call a method from another script?,Does not contain a definition for and no accessible extension method accepting a first argument errors 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges