Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 TristenB. · Sep 24, 2014 at 02:03 AM · errornoobparsing

I have a parsing error. and yes, I am a noob.

Line 35,1

 using UnityEngine;
 using System.Collections;
 
 public class FlashLightController : MonoBehaviour 
 {
 
     public Light flashlightObject;
 
     void Start () 
     {
 bool  flashlightObject = false;
     }
     
 
     void Update () 
     {
     if(Input.GetKeyDown(KeyCode.Mouse0))
     {
             if(flashlightObject.enabled == false)
             {
                 bool flashlightObject = true;
             
 
         }
             else
             {
              flashlightObject = enabled = false;
             }
 
         }  
 
     }
 
 }
 }
 }

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
2

Answer by rutter · Sep 24, 2014 at 02:05 AM

You have unbalanced {} braces. Generally speaking, each { opening brace should have a matching } closing brace. It's easier to keep track of that if your code is organized (which yours mostly is).

Lines 35 and 36? They're extra braces you don't need. Delete them.

After that, you'll need to fix lines 11, 21 and 27. You might be a little confused about how you set the enabled property:

 flashlightObject.enabled = false; //example

You can also toggle a boolean value with the ! operator, also called "logical NOT":

 flashlightObject.enabled = !flashlightObject.enabled; //toggle
Comment
Add comment · Show 1 · 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 HarshadK · Sep 24, 2014 at 08:05 AM 0
Share

Just one addition, declaring a variable inside {} braces will make that variable available inside those {} braces only. And you are actually doing it on your line #11 and line #21 where @rutter has actually provided you with the correct logic which does not care for this issue.

But just so you know, if you want to use a variable inside from any method in your script or even from another scripts then you should declare them where you have declared your

 public Light flashlightObject;

where you can list all your variable declarations below current declaration. Also to be able to access that variable from other scripts it should be public.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Enter Trigger, display Text, then delete object 1 Answer

Parsing error CS8025 0 Answers

NullReferenceException 3 Answers

CS8025 ERROR : Camera Script 1 Answer

error CS8025: Parsing error in C# code 3 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