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
1
Question by Sendatsu_Yoshimitsu · Sep 19, 2017 at 08:14 AM · editor-scriptingserializationscriptableobject

Why aren't lists editable in ScriptableObjects?

I'm trying to make a ScriptableObject I can use to define NPC movements in the editor by creating an instance of the SO for each NPC, populating it in-editor, then leaving it in the resources folder to be loaded at runtime when required. The implementation is pretty trivial:

 [System.Serializable]
 public class CharacterScheduleEntry
 {
     public string sceneName;
     public int progressionFlag;
     public string spawnPoint;
     public string dialogueKey;
 }
 
 [CreateAssetMenu(menuName = "Character Schedule")]
 public class BaseCharacterSchedule : ScriptableObject {
 
     public string characterKey;
     public List<CharacterScheduleEntry> scheduleList = new List<CharacterScheduleEntry>();
 }

This looks fine, but when I actually create an asset of type BaseCharacterSchedule, scheduleList is visible but always has 0 indices; if I attempt to manually change its size to anything, it immediately reverts back to 0. I've tried playing/stopping and restarting the editor, and even changing scheduleList's type from my own custom class to , but nothing seems to work- is it simply not possible to use lists in a SO?

Comment
Add comment · Show 11
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 Adam-Mechtley · Sep 19, 2017 at 08:32 AM 0
Share

Do you have a custom editor for BaseCharacterSchedule? Is this the entirety of the code for BaseCharacterSchedule?

avatar image Sendatsu_Yoshimitsu Adam-Mechtley · Sep 19, 2017 at 08:42 AM 0
Share

That is indeed the entirety of the code for it- is a custom editor required? I assumed that since the component variables were all simple types, I could get away with just editing the list directly.

avatar image Adam-Mechtley Sendatsu_Yoshimitsu · Sep 19, 2017 at 08:47 AM 0
Share

No it is not required, but the symptom you described is common in custom editors that have been implemented incorrectly.

Show more comments
avatar image Adam-Mechtley · Sep 19, 2017 at 09:02 AM 0
Share

I tried using your example code verbatim and cannot reproduce the problem. Everything seems to work for me as expected.

I'm assu$$anonymous$$g this is the only place you're seeing this problem? $$anonymous$$g., you don't have an event handler for Undo.postprocess$$anonymous$$odifications somewhere?

avatar image Sendatsu_Yoshimitsu Adam-Mechtley · Sep 19, 2017 at 09:10 AM 0
Share

This is definitely the only place I'm using it, since I made both classes brand-new to work out how to use scriptableobject... are you on 2017.1.0p4? Because I just created a brand-new project as well, but cutting & pasting the code I posted above results in the same weirdness.

I did find a reproducible way to eli$$anonymous$$ate the problem, but it's weird as heck- if I include multiple, identical lists, like the following, every list but the bottommost is editable:

 public List<CharacterScheduleEntry> characterSchedule1;
 public List<CharacterScheduleEntry> characterSchedule;
 public List<CharacterScheduleEntry> characterSchedule0;


Apparently it's not limited to lists, as creating a filler int under the list, editing the asset in the inspector, then deleting said int leaves the list editable. I must be doing something weird here by mistake, but it bugs me that I can repro it in a clean project.

avatar image Adam-Mechtley Sendatsu_Yoshimitsu · Sep 19, 2017 at 09:14 AM 0
Share

Does this happen for you in an official (i.e. non-patch) release?

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

80 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

Related Questions

Add lines to a script from another script 0 Answers

Serialization issue with ScriptableObject 0 Answers

How to work with custom class (ScriptableObject) SerializedProperty? 1 Answer

Why is play mode reverting my scriptableobject to a previous serialized state? 2 Answers

[Solved]How to serialize Dictionary with Unity Serialization System 6 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