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 Yarden-Raveh · Feb 23, 2014 at 05:17 PM · editorbuild-errornullreferenceexceptionnull reference

NullReferenceException Error

So this is the deal. I have no error in the editor and everything is running smoothly. However when i run my build a script doesn't work. I checked the output log and i saw this message:

NullReferenceException: Object reference not set to an instance of an object at Matrix_Node_Row.updateCurveData (UnityEngine.AnimationCurve curveData) [0x00000] in :0

at Matrix_Node_Row.Update () [0x00000] in :0

(Filename: Line: -1)

So i went to the Matrix_Node_Row Class and checked the updateCurveData function. Here it is:

     public void updateCurveData(AnimationCurve curveData){
         if (curveData==null)
         {
             Debug.Log ("object "+this.ToString()+"is trying to run a null curveData");
         }
         if (this.curveData!=null || animateEnabled==true)
         {
 
             for (int i=0; i<row.Length; i++) {
                 row[i].inputCurveData (curveData.Evaluate ((i*step)+p_offset));
             }
         }
     }
     public void updateCurveData(float curveData)
     {
         if (curveData==null)
         {
             Debug.Log ("object "+this.ToString()+"is trying to run a null curveData");
         }
             if (this.curveData!=null || animateEnabled==true)
             {
                 for (int i=0; i<row.Length; i++) {
                     row[i].inputCurveData (curveData);
                 }
             }
     }


The Update function looks like this:

 if (animateEnabled)
         {
             updateCurveData (curveData);
             //updateColorData (colorData);
         }

The debug meassage is not written to the log so curveData can't be null. I don't understand where something like this can stem from and i need to present my work tommorow!!

Comment
Add comment · Show 8
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 Jamora · Feb 23, 2014 at 05:19 PM 1
Share

Have a read of my explanation of null reference errors in this answer. The curveData passed to the method can never be null, because it is not a reference type.

avatar image Yarden-Raveh · Feb 23, 2014 at 05:26 PM 0
Share

Ok, so curveData could point to a null reference, but how could there be null a refence if this script ran completely fine in editor? This error only comes up after i build my project.

avatar image Jamora · Feb 23, 2014 at 05:32 PM 1
Share

curveData is not the cause of this error, because you check if it is null. If it were null, you'd get the printout.

Something else is causing the error, and my explanation in the link I gave you in the above comment will tell you where to look.

avatar image KiraSensei · Feb 23, 2014 at 06:18 PM 1
Share

You are testing curveData (the local variable co$$anonymous$$g from the function call, and then you test this.curveData, but you use curveData. They are not the same variable ! $$anonymous$$aybe your problem is from this misunderstanding...

avatar image AlucardJay · Feb 23, 2014 at 06:23 PM 1
Share

Terrible Question Title Award Winner of the day

Edit : Why? Everyone who asks a question here wants help. How is this more important? Overuse of punctuation. There is an abundance of question titles already using NullReferenceException.

  • to Jamora for a great link

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Yarden-Raveh · Feb 23, 2014 at 06:41 PM

Thanks to everyone who replied, i have found the answer. I had to initialize objects prior to the start of the scene in order to keep the scene optimized. I placed these operation in OnValidate since i also wanted to make sure they were of a specific type. However i forgot to copy the initialization operation to the Awake function. So the array row was intialized in editor but not in build.

Comment
Add comment · 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

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

22 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Problems with Builds 1 Answer

NullReferenceException from a script after linking prefab with drag and drop in inspector. WTF? 1 Answer

AutoComplete Text in TextField 2 Answers

Problem with array on gameobjects 2 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