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 superventure · Jun 29, 2013 at 12:02 PM · dataeditlose

Why does saving a script in runtime lose in game data?

I remember in the earlier versions of unity that when you saved any changes to a script while playing live in the engine, that it didn't lose information in game, it just updated... What happened? When I save a change in any script during run time (even non relevant), it loses all data set from awake and start functions and so forth, and I have to restart the game play to get current with any new code I set. I HATE THIS! I test out a lot concepts for my games and having to restart plays from the beginning just because I changed one simple thing in a script is driving me crazy.

Is there a way to bypass this? Am I missing something in the new version?

I have heard of player prefs but is really necessary for just updating a script while playing in the engine itself?

I have a ton of scripts so when I save in any one of them, it takes forever to update.

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 Benproductions1 · Jun 29, 2013 at 12:34 PM 0
Share

This is only the case for variables that are not of certain types. Like Array's and any .NET classes are reset, while variables of type int and float are not.

From my experience, it's not much of a problem. I just make it a habit of not coding while it's playing.
Compared to other engines, you should be glad of the click to play function :)

1 Reply

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

Answer by Jamora · Jun 29, 2013 at 01:02 PM

Sounds like an issue with serialization. Check out this blog: http://blogs.unity3d.com/2012/10/25/unity-serialization/ . They talk about EditorWindows, but it's all applicable to the inspector as well.

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 superventure · Jun 29, 2013 at 02:39 PM 0
Share

Looking into it, this does seem to be the issue. Thank you. After researching, I learned about lists, but adding it to js always throws me errors- I think it has something to do with the code #pragma and that I have getcomponent within the script I need lists for. Could you please elaborate?

avatar image Benproductions1 · Jun 30, 2013 at 02:03 AM 0
Share

Any .NET classes work with #pragma strict, you are probably just using them wrong ;)

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

17 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

Related Questions

Smootlookat modified script 1 Answer

Modifying mesh vertices in an editor script 2 Answers

How can I lose health when my enemy collides with the player? 1 Answer

Reading data from one script to another 0 Answers

Is there a "Lightweight Monobehaviour"? 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