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 eladiozro · Nov 05, 2018 at 05:08 PM · publicpublic variable

My public variables are gone after opening Unity the next day.

Hello, so my problem is that I have opened Unity the next day, but when I see the public variables on my scripts, they are now empty. How can I fix this, or how can I see a file that enables me to make sure all this information is being stored safely. Thanks.

capture2.png (25.8 kB)
capture3.png (31.8 kB)
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 dan_wipf · Nov 05, 2018 at 05:40 PM 0
Share

do they have a custom editor script?

3 Replies

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

Answer by eladiozro · Nov 05, 2018 at 07:24 PM

Thanks, yeah, you're right, by the way the information was restored after refreshing a little the GameObjects ( I think it was the scene what was reloaded ), so the information was there, but it wasn't being able to access it.

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 AaronXRDev · Nov 05, 2018 at 05:31 PM

This is pretty uncommon but can happen if the GameObject or script gets removed and re-added or duplicated (the duplicate will be empty but the original should be intact).


Usually the best way to prevent this is to use some sort of source control like Git or Unity's own Collab feature. That way you can revert to a previous good state and work from there if you need to.

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 eladiozro · Nov 05, 2018 at 05:53 PM 0
Share

Yeah the thing is that just turned off the PC and the next day this this happened, but Is there any file that stores this information so I can make sure it's safe.

avatar image
0

Answer by swanijam · Nov 05, 2018 at 05:50 PM

Are you sure that these are the same instances of the scripts in the same scene from yesterday, and that you remembered to save your scene changes after working yesterday? The public variables plugged into any component are saved in the scene file, and only for each specific instance of the script. If your scene file was not saved, or was corrupted, or if these are new instances of these scripts, or if you only set those values in play mode, these components would have null values in their public fields.

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 eladiozro · Nov 05, 2018 at 06:16 PM 0
Share

It might be because of some errors in the script, and because of maintaining those errors the next day it was null. So isn't there any way to maintain the public variables info 100% safe, like in a very long string that can't be modified, or something?

avatar image swanijam eladiozro · Nov 05, 2018 at 06:44 PM 1
Share

I don't think unity would be able save any info about the component if the component failed to compile. It would retain all the data from the last version of the component instance that wasn't broken ( I think). I doubt it would be worth all the extra time required to override Unity's system of referencing/ serializtion (assu$$anonymous$$g it's possible), but what you could do before shutting down or closing untiy when you have errors, to preserve your variables, is comment out all the code inside the offending functions until there are no errors, save the script and then the scene, and then uncommenting out those lines so you still have error messages to return to next time.

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

97 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

Related Questions

Why can't I to declare public the variable "Clave"? 1 Answer

How to make variable accessible by other scripts but not visible in editor? 1 Answer

Cannot assign Public GameObject variable in Inspector... 2 Answers

Referencing variables via external script? 1 Answer

How can I get a data from function to other function? 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