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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
1
Question by douglassophies · Sep 10, 2012 at 03:10 AM · editorlistarrayselements

Populating a list in the editor

I am trying to make a list that can be worked with in the editor. Every time a new element is added, it should automatically be filled with an object that holds a series of variables with their default values. Right now, i can change the size of the list, but the elements are empty. Thanks in advance for any help. Let me know if you need a code example and i will try and figure out how you do that here!

I feel this is a really simple problem, but i am stumped and cannot find anything online. Anyone able to point me to an example or an explanation?

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

Answer by whydoidoit · Sep 10, 2012 at 03:15 AM

Make a [Serializable] class that contains your variables and in the class definition set the default values. Then make a public array or list of the class and new items will be initialized for you.

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 douglassophies · Sep 10, 2012 at 02:13 PM 0
Share

Thanks for the help, but i am still having a little trouble. I have added the [System.Serializable] just above the class that contains the information i wish to hold in my list. The other script file that creates the list looks likes this - public List animationSets = new List(); But when i add a new element it is still co$$anonymous$$g up empty. Specifically the editor looks like this - "Element 0 None (Animation Framesets)". So i guess it knows it is supposed to hold instances of the AnimationFramesets class, but i needs a line where i tell it to create one for each new added element. Tried numerous solutions but none seem to work.

avatar image
0

Answer by douglassophies · Sep 14, 2012 at 07:50 AM

I finally worked out the answer. The class i wanted to serialize was extending from MonoBehaviour. I got rid of that and it worked fine.

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 whydoidoit · Sep 14, 2012 at 08:49 AM 0
Share

Oh sorry - that is what I was suggesting - I clearly didn't make a good job of explaining it though!

avatar image douglassophies · Sep 14, 2012 at 09:20 AM 0
Share

You gave me a keyword with [Serializable] which enabled me to search for it myself so I still appreciate the help!

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

9 People are following this question.

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

Related Questions

A node in a childnode? 1 Answer

Is there a way to remove array entries in the editor? 4 Answers

Variables inside an element list 1 Answer

Using Generic List with serializedProperty Inspector 3 Answers

How To Get A Reference To All Nearby GameObjects? 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