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 /
  • Help Room /
avatar image
0
Question by rakso13 · Feb 08, 2019 at 06:54 AM · scenedestroyvariableerror messagecomponent

random loss of component variable value

This thread is on hold while I'm doing some testing, my conclousions beneth seem to be incorrect, need to update everything


I'm working in 2 scenes, creating an object with an UI Image that I hooked up to a variable. Can use it without problem. Then when changing scene the variable works until i disable the image component, right after nothing happens but when i try to activate it via the variable I get a message that the component Im refering to is destroyed. I have 0 clue what is going on. pls help, just a theory, anthing im desperate. thnx

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

2 Replies

· Add your reply
  • Sort: 
avatar image
3

Answer by tormentoarmagedoom · Feb 08, 2019 at 08:45 AM

Good day.

You disable the image? How? Did you check in inspector is still there? Are ypu sure the error refears that image? Are you not destroying it? What and how are you disabling and reactivating it? Did you changed scenes.

Check and be sure at 100% with no doubt all that questions. Post the code lines that gives you the error.

Im thibking now... If you changed scenes, except for all 'NoDestoyOnLoad' objects, all other are destroyed. If you are trying to refear something from the last scene will give you that errro. You need to find that image again, and if is not active, ypu need to assign it via inspector.

Good luck! Bye!

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
1

Answer by rakso13 · Feb 08, 2019 at 03:56 PM

:void start(){

:Image comp = GetComponent();}


:public void enable(bool enable){

:comp.enabled = enable;

:debug.Log(comp);}


when enable = false, it works

when enable = true, it does not work

I get the message: missing refrence exeption: the object of type "Image" has been destroyed but you are still trying to acces it.

the function works as intended in the first scene but in other scenes I get this problem. If I go to another scene and then back to the first scene it works, but get the error. Also if I try to acces the component variable in an update loop in the same class, it works all the time. message.@tormentoarmagedoom

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 rakso13 · Feb 09, 2019 at 10:05 AM 0
Share

Update: it works if I ins$$anonymous$$d have a bool that I change and depending on that the image gets enabled or disabled. But ins$$anonymous$$d I change the image component in the update function. works perfect but inneficient. I also change some textcomponents for the childs of the object and i get the same problem in the function. But it gets solved in the same way

avatar image rakso13 · Feb 09, 2019 at 10:10 AM 0
Share

No wait, new Update. It seems like it's 2 separate classes that are not connected. I'm gonna have to look into some more into this

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

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

Scene 'Assets/First level.unity' (-1) couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded. 11 Answers

Can I Reference Object Components from another Scene? 0 Answers

UnityYAMLMerge error: Cannot find transform parent for fileID 0 Answers

Make a Scene variable 0 Answers

No error code? Not sure where to go? 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