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 djkr · Sep 08, 2011 at 03:35 PM · nullreferenceexception

Null Reference Problem - Emergency - Help! (same prob/diff variables)

Hi... Having " NULL REFERENCE " Problem, even though the variable is set to '1', its coming up somewhere as NULL - then in mid loading- I'm getting this error:

The main problem is now this:

 I found another place the error has jumped to.

Fixed some things,but had an error in this next section (Line 99):

 // GUI MATRIX
 if(matrixAngle != previousAngle || matrixPosition != prevMatrixPosition) { //only calculate new Quaternion if angle changed
     quat.eulerAngles = Vector3(0.0, 0.0, matrixAngle);





(It says the cause is x 2: swipeCtrl.maxValue = 1; and var offset : float = swipeCtrl.smoothValue - Mathf.Round(swipeCtrl.smoothValue); and the second problem. NOTE: I have multiple scripts that are copied with different title names - but same programming - just changed the titles of the files, and the name of some variables to suite the multiple copies of this script.

NullReferenceException: Object reference not set to an instance of an object ImageDisplay4.Awake () (at Assets/Scripts/ImageDisplay4.js:63) UnityEngine.Object:Instantiate(Object) $:MoveNext() (at Assets/viewer-scripts/LOADCONTROL.js:265)

Here is the main chunk of code thats having the problem..

     //Set up SwipeControl
 //swipeCtrl.partWidth = img.width;
 swipeCtrl.maxValue = 1;
 if(expandInputAreaToFullWidth) {
     swipeCtrl.SetMouseRect(new Rect(-Screen.width * 0.5, imgRect.y, Screen.width, imgRect.height)); // Use image-height for the input-Rect, but full screen-width
 } else {
      swipeCtrl.SetMouseRect(imgRect); //Use the same Rect as the images for input
 }
 swipeCtrl.CalculateEdgeRectsFromMouseRect(imgRect);
 swipeCtrl.Setup();
 /*
 //Determine center position of the Dots
 if(dotRelativeCenterPos == Vector2.zero) dotRelativeCenterPos.y = imgRect.height * 0.5 + 14;
 dotRelativeCenterPos = new Vector2((imgRect.x + imgRect.width * 0.5) + dotRelativeCenterPos.x, (imgRect.y + imgRect.height * 0.5) + dotRelativeCenterPos.y);

/ if(centerMatrixOnScreen) { matrixPosition.x += Mathf.Round(Screen.width 0.5); matrixPosition.y += Mathf.Round(Screen.height * 0.5)+176;//this is it adddown spawn extra space down }

}

function OnGUI () {

 // GUI MATRIX
 if(matrixAngle != previousAngle || matrixPosition != prevMatrixPosition) { //only calculate new Quaternion if angle changed
     quat.eulerAngles = Vector3(0.0, 0.0, matrixAngle);
     previousAngle = matrixAngle;
     matrix = Matrix4x4.TRS(matrixPosition, quat, Vector3.one);    //If you're no longer tweaking
     prevMatrixPosition = matrixPosition;
     swipeCtrl.matrix = matrix; // Tell SwipeControl to use the same Matrix we use here
 }
 GUI.matrix = matrix;        


 // IMAGES
 var offset : float = swipeCtrl.smoothValue - Mathf.Round(swipeCtrl.smoothValue);
 var mainPos : float = imgRect.x - (offset * imgRect.width);
 if(Mathf.Round(swipeCtrl.smoothValue) >= 0 && Mathf.Round(swipeCtrl.smoothValue) < 1) {
     GUI.color.a = 1 - Mathf.Abs(offset);
     GUI.DrawTexture(new Rect(mainPos, imgRect.y, imgRect.width, imgRect.height), img);//[Mathf.Round(swipeCtrl.smoothValue)]);

// GUI.DrawTexture(new Rect(mainPos, imgRect.y, imgRect.width, imgRect.height), img);//[Mathf.Round(swipeCtrl.smoothValue)]);

 }

Thanks for the help, in advance...

Kris

Comment
Add comment · Show 4
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 djkr · Sep 08, 2011 at 03:40 PM 0
Share

F.Y.I. - I tried setting the first part (quoted above) to "0" (zero) - with NO Effect...

avatar image Sydan · Sep 08, 2011 at 03:42 PM 0
Share

It's hard to work out what's happening in this code, which is line 265?

avatar image Sydan · Sep 08, 2011 at 03:52 PM 0
Share

And also which line is 63?

avatar image SisterKy · Sep 12, 2011 at 08:10 PM 0
Share

I appreciate that you deleted your answer.
I wasn't saying you can't post your whole code, but to do it in your original question and to format it properly... at the end of your question, at the left, quite small and light gray there's a button 'edit'. If you click it, you can fix up your original post with more information. remove the old code. then paste the full new code. Select the full new code. Then hit the little 101010 button...

2 Replies

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

Answer by djkr · Sep 13, 2011 at 07:35 PM

Found the Solution:

Thanks for your replies!... I ended up creating a prefab that I could drag and drop into the Variable that had the Null (within Unity 3D).

Again, I appreciate your responses!

Cheers, Kris

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 SisterKy · Sep 13, 2011 at 07:40 PM 0
Share

Glad you found your solution :)
Please click on the little check mark to the top left of this answer to mark it as 'the answer', so that this question turns green and everyone can see from the outside that this is solved =)

avatar image
0

Answer by SisterKy · Sep 08, 2011 at 06:43 PM

Are you accessing swipeCtrl anywhere above the line where you get the error and it is successful? (I guess not)
My bet is you try to reference some SwipeControl-script but this assignment fails. Now if you try to access a variable in the SwipeControl-script (that has not been referenced successfully) it gives you the nullreferenceexcept. So your problem is most likely somewhere above the code-sniplet you posted.

http://answers.unity3d.com/questions/47830/what-is-a-null-reference-exception-in-unity.html

Greetz, Ky.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

EditorApplication.OpenScene causing NullReferenceException 1 Answer

NullReference in Start() or Awake() when testing on Android device, works fine in Editor 2 Answers

NullReferenceException when using Single Joystick prefab 1 Answer

Can't seem to pull timestamp from networkmessageinfo in OnSerializeNetworkView 1 Answer

Shooting Script Instantiate Problems. Help? 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