Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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.

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

get my scripts to talk to each other 2 Answers

AudioSource.PlayClipAtPoint creating unlimited AudioOneShot 1 Answer

Rocket Projectiles in Flight Simulator error 1 Answer

Dont know what im doing wrong?(Error included) (Javascipt) 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges