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 vtcb · Nov 28, 2016 at 08:06 AM · nullreferenceexceptionmissing script

Script component disappears randomly in runtime

I have already searched for it, but all I can find is about this error appearing when the game is played or something like it. That's not my case.

My game works fine for some time, but then, randomly, I get this error:

"The referenced script on this Behaviour is missing!"

After that I get some NullReferenceException. Apparently my script components disappear.

This has happened to more than one script, and I can't see any link between them.

What could be causing this?

Comment
Add comment · Show 1
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 giantkilleroverunity3d · Apr 14, 2019 at 08:35 PM 0
Share

I have this happening right now. I use ProcedureLightning and the asset prefab is removed from the hierarchy. When I stop the runtime the prefab is there back in place.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Apr 15, 2019 at 12:07 AM

This happens when you have a script attached to an object (in the scene or a prefab) and you

  • deleted your actual script file from your project.

  • you moved it to a different folder outside of Unity without the corresponding meta file.

  • you renamed either the class or the file the class is defined in so the script can no longer be used.


To fix this problem, first make sure your script and the file it contains both have the same name. Now you have two options:

  • Either just delete the old component from your gameobjects and re-add the script.

  • If you originally had many settings and you don't want to loose those settings, you can keep the broken component and re-link the script file. To do this switch your inspector into debug mode (context menu at the top right of the inspector). Once in debug mode your component should have a script field. Now you can simply drag the correct script onto that variable and the component should work again. Just don't forget to switch the inspector back to normal mode.

Comment
Add comment · Show 2 · 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 giantkilleroverunity3d · Apr 15, 2019 at 03:04 AM 0
Share

I found this: onDestroy() is called only when system is low on resources(memory, cpu time and so on) and makes a decision to kill your activity/application or when somebody calls finish() on your activity. A comment was in this: https://stackoverflow.com/questions/4449955/activity-ondestroy-never-called

I have a performance problem. This is why this is see$$anonymous$$gly random. I have narrowed down an operation scheme and can cause it to happen on purpose. Now I can adjust operational parameters to quiet the issue down to a tolerable level in Unity. Or this will just become an apparent thing that I have to circumvent in another fashion.

avatar image Bunny83 giantkilleroverunity3d · Apr 15, 2019 at 03:11 AM 0
Share

No, no, no. You're completely off-topic here. Please stop posting on completely off topic threads. When we talk about OnDestroy or destroying gameobjects we talk about within the Untiy environment. What you're referencing with that SO question is pure Android OS and activity stuff. Yes, when you build for android Unity will be an activity within the Android OS. However the OS does not destroy individual things inside an activity. The OS will kill inactive / suspended activities if it requires memory. However activities are either killed completely or not.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Why am I getting a NullReferenceException while trying to set a gameobjects animation frame? 0 Answers

NullReferenceException .. problem with Camera.main.transform 2 Answers

Raycasting null object reference error 1 Answer

Editing in Animator removes Player tag 0 Answers

NullReferenceException: Object reference not set to an instance of an object 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