• 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 Koyemsi · May 08, 2018 at 11:56 AM · arrayinspector

Keep values in inspector while changing variable name

Hi everybody.

I have a public GameObject[] array named myArray.

In the inspector, I filled it with many GameObjects.

For some reason, I want to change the array's name for a better one, like myGameObjects. But if I do so, I will loose all the values I had put in the inspector. Any way to avoid this ?

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
1
Best Answer

Answer by Adam-Mechtley · May 08, 2018 at 01:16 PM

You can use the FormerlySerializedAsAttribute to rename a field and retain your saved data. The next time the component/scriptable object is deserialized it will be automatically upgraded, and the next time you save it to disk it will be serialized with the new name.

Comment
Add comment · Show 3 · 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 Koyemsi · May 08, 2018 at 02:26 PM 0
Share

Great, seems to be exactly what I was looking for. I must say that the subtleties of serialization are still a bit obscure to me. Thanx a lot.

avatar image Adam-Mechtley Koyemsi · May 08, 2018 at 03:28 PM 0
Share

If it helps, I recommend the Script Serialization section of the docs

avatar image Koyemsi Adam-Mechtley · May 08, 2018 at 04:39 PM 0
Share

Yes, I think reading this will definitely help. I put it on my (already long) to-learn list.

Thanx again.

avatar image
0

Answer by anthot4 · May 08, 2018 at 11:57 AM

No there isn't as far as I know. Just write down all the gameobjects you had in the array before you rename it.

Comment
Add comment · Show 4 · 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 Koyemsi · May 08, 2018 at 12:16 PM 0
Share

I was hoping there would be some kind of dynamic link. Thanks anyway for the answer.

avatar image Koyemsi · May 08, 2018 at 02:29 PM 0
Share

Sorry for the down vote, @anthot4, it's purely accidental. I keep on trying to upvote your answer, but it keeps displaying negative values. The best I can do is keep it to zero. $$anonymous$$y apologies.

avatar image anthot4 Koyemsi · May 08, 2018 at 02:37 PM 0
Share

No Problem. :)

avatar image Koyemsi anthot4 · May 08, 2018 at 02:50 PM 0
Share

Thanx for your comprehension. I was feeling so sorry when, trying to upvote, I saw the values going down to -2, -3... What the hell ?! Don't know if it's a website bug. $$anonymous$$aybe I should consider getting rid of Safari once for all.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

[SOLVED]How to use attributes from array of custom class instances? 1 Answer

Development of the shop? 1 Answer

How to change array orders in the inspector 1 Answer

How to check if inspector-filled array is empty 0 Answers

GUI, Inspector has no control for Arrays? 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