简体   繁体   中英

Using a C# list in a Scriptable Object unity

had two questions about using lists within a scriptable object in unity, id like to basically add a list that holds answers to a question which are part of an MCQ style project im working on, here is the code i use to create text area within the inspector

[SerializeField]
[TextArea(1,2)]
[Range(1,5)]
List<string> answerList = new List<string>();

Im able to see the list within the inspector but i run into two issues, the first one is that the 0th element seems to be minimized always, and the second issue is that i'd like the user to only enter 5 possible answers for now but the range attribute seems to be ignored, so im not sure if the range attribute will work for this case because i am able to create a list in the inspector which is greater than 5. I've attached an image to show this, any help would be great, thanks guys.

在此处输入图像描述

所以我做了一些挖掘并设法找到一个解决方案来阻止列表增加超过最大上限大小,只是使用了 onvalidate 函数,仍然对为什么第 0 个元素被最小化感到困惑。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM