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 pippo19 · Dec 03, 2013 at 09:04 PM · errorjavaprogram

Error that I can not solve

hello to all I was presented this error

alt text

but I do not understand what is the cause ... how can I solve it?

immagine.png (11.2 kB)
Comment
Add comment · Show 3
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 Graham-Dunnett ♦♦ · Dec 03, 2013 at 09:05 PM 0
Share

What is line 180 of your control.js script? Unboxing means the runtime is trying to convert an object from one class to another.

avatar image ashjack · Dec 03, 2013 at 09:56 PM 0
Share

We need the script that is causing the error otherwise we can't help.

avatar image oliver-jones · Dec 03, 2013 at 10:43 PM 0
Share

Open up your script called control.js, then go down to line 180 and copy and paste that section of code into here so we can help you.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · Dec 04, 2013 at 03:38 AM

Well, like others said without seeing the code it's hard to give a clear advice, however i try to explain what might cause thie error.

I guess you used an untyped variable to store a float value or any other kind of value type. An untyped variable is automatically typed as "object". Value types (floats, ints, structs, ...) have to be "boxed" when they are stored in an untyped variable. Boxing means that the value is placed on the heap. The system will allocates memory so it can be treated like an object.

On the other hand when you assign an untyped variable to a valuetype, the system has to read out the actual value from the referenced memory address and copy it into the value typed variable. This is called unboxing. The problem is that an untyped variable can be null. If the system tries to unbox a variable that is null, a null reference exception occures.

So you probable have a variable like this:

 var someVar;  // untyped variable

which is null and you try to use it as value type which will make the system unbox the null-reference:

 // example
 transform.position = Vector3(someVar,0,0); // unboxing to float --> error if someVar is null

To fix this you should:

  • make sure you use "`#pragma strict`" at the top of your script.

  • type all of your variables.

The first point enforces the second.

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
avatar image
0

Answer by belvita · Dec 03, 2013 at 10:46 PM

Unity can not find the object you want to create ,check ur code carefullyc.check if u attached ur prefab to a public variable from inspector if u using prefabs

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

20 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

Related Questions

Boat script problems when changing platform to android 0 Answers

Animation script error 1 Answer

Console Error 1 Answer

Getting this error when trying to run a game on android 2 Answers

JNI error when calling Java plugin from System.AppDomain.CurrentDomain.UnhandledException callback handler 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