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 /
This question was closed Aug 27, 2017 at 12:21 PM by hexagonius for the following reason:

https://docs.unity3d.com/Manual/NullReferenceException.html

avatar image
0
Question by legowill6 · Aug 27, 2017 at 12:18 PM · javascripterrornullreferenceexception

Object reference not set to an instance of an object help (JS)

Hi all,

Here is my code that checks to see a if a int variable is between different ranges by using if statments.

There's probably a more elgant way of doing this but the error I am getting is an NullReferenceException: Object reference not set to an instance of an object. I know this error means it can't access something vital but in the inspector everything is enabled and the scripts are connected with game objects. Here is my code and a screenshot to prove that.

 function Start(){
     if (File.Exists(fileName))
     {
         var sa = new StreamReader(fileName);
         var fileContents = sa.ReadToEnd();
 
         scorecounter.text = fileContents.ToString();
         sa.Close();
 
         var intfilecont = fileContents.parseInt;  //error happens here
 
     
         if (intfilecont > 0 && intfilecont < 21){
             comment.text = "POTATOE Damn son, invest in a better PC";        
          }
          if (intfilecont > 19 && intfilecont < 31){
             comment.text = "BRONZE git gud m8";        
          }
          if (intfilecont > 29 && intfilecont < 41){
             comment.text = "SILVA Your PC is c00l and g00d";        
          }
          if (intfilecont > 39 && intfilecont < 51){
             comment.text = "G0LD Wow! very nice mate";        
          }
          if (intfilecont > 49 && intfilecont < 69){
             comment.text = "PLATINUM YO IS YOUR PC LIT? like is it literally on fire now?";
          }
          if (intfilecont == 69){
             comment.text = "MLG You must be the luckiest quick scoper to live m9";
          }
          if (intfilecont > 69 && intfilecont < 90){
             comment.text = "SUPER SAIYAN to go even further beyond!";        
          }
          if (intfilecont > 99){
             comment.text = "NASA wtf do you have a super computer?";        
          }
     }
 }
 
 
 ![alt text][1]
 
 

There is more code above this that isn't attached to the problem if you were wondering.

I don't know what is happening and would appreciate any help.

[1]: /storage/temp/100758-proof.png

proof.png (17.9 kB)
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

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

130 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 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

Hi I get an error code when i'm using my Javascript and I can't understand how to fix it... :( 1 Answer

NullReferenceException: Object reference not set to an instance of an object 1 Answer

[js]NullReferenceException: Object reference not set to an instance of an object 1 Answer

What is wrong with my script? 1 Answer

Another NullReferenceException: question...(Java) 1 Answer


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