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 Adamcbrz · May 04, 2012 at 11:01 PM · editorlistserializable

Editor Script not saving after first time playing

This is a very weird behavior. I have a very complex editor script and it seems like it will only save the first time I use it before I hit the play button. Here is my step by step.

  1. Create GameObject

  2. Attach A Script

  3. Open Editor Window

  4. Adjust setting in Editor Window

  5. Hit Play (everything is still there)

  6. Hit Play (to stop)

  7. Adjust setting

  8. Hit Play...the changes revert to Adjustment in step 4

  9. Go edit any script in my project

  10. Adjust settings in Editor Window

  11. Hit Play...everything saves again but only this time

I am using EditorUtility.SetDirty to save the info to my script attached to my GameObject. And I have Serialized every field and class, probably more than it needs. I will try to get a simplified example upload later.

[EDIT] I am adding an example package that is simplified version of what I am experiencing. You can open the window when in Unity going Window > Test Editor

http://dl.dropbox.com/u/22440911/TestScript.unitypackage

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 Adamcbrz · May 05, 2012 at 11:47 PM 0
Share

anyone have any ideas?

2 Replies

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

Answer by Adamcbrz · May 07, 2012 at 03:16 PM

I found a solution to my problem. It appears that I am loosing my reference to the MonoBehavior when I hit play. What i am doing is probably overkil but I am re finding the script OnEnable, OnSelectionChange, OnFocus, and OnHierarchyChange. That caused it all to work perfectly. I am sure this is not the optimal method of doing this but it works for now.

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 ABerlemont · Apr 19, 2013 at 11:09 AM 0
Share

Can you be more specific with that solution ? What do you mean by "re finding" ? Thanks.

avatar image
0

Answer by fafase · May 07, 2012 at 01:32 PM

When variables are public they are shown in the Inspector.

The values given to the variables in the script will be used only the first time. After, you need to change them from the Inspector. Chnaging them in the script editor won't alter them in the script. Only the constants will be changed from editor script.

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 Adamcbrz · May 07, 2012 at 02:18 PM 0
Share

Ok sounds good. Is there anything I can do to solve this issue. What do you mean by "constants"?

avatar image fafase · May 07, 2012 at 03:53 PM 0
Share

Constant is like numbers. If you have

position.x += 10;

and

var speed:int =10; position.y += speed;

speed is a variable, if declared as public you will alter it from the inspector. If you get back to the editor and give it value 100, it won't change for all the objects you have already assigned the script. If you assign it to an object after alteration, then this object has the new value.

10 is a constant number, you cannot modify its value. But if you change 10 for 100 then it moves 10x faster.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

List Contains false after playmode 0 Answers

A node in a childnode? 1 Answer

SerializeField does not work when a value set using code 0 Answers

How do i go about generating stuff in editor and keeping it in play mode 2 Answers

adding items to my list 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