Resize Serializable List size

Currently I have a serializable class called QuestionAnswers with the following :

public string question;
public string[ ] answers;
public int correctAnswer;


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class QuestionAnswers
{
public string question;
public string[ ] answers;
public int correctAnswer;
}


In my normal MonoBehaviour script called ListManager I reference the serializable class called QuestionAnswers as QnA:

public List QnA;


public class ListManager : MonoBehaviour
{

public List QnA;


in the inspector the public List QnA shows as below

6980735--823586--upload_2021-3-27_18-24-33.png

My question is how can I change the QnA size value (currently 1, as shown above) and the Answers Size value (currently 4, as shown above) in my ListManger script via an inputfield.text field.

Note that the structure of the List QnA(as shown above) should stay the same as the correct answer value is connected to the answers and the answers is connected to the question.

Example :

When I increase the QnA size value to say 3 the inspector shows following :

6980735--823592--upload_2021-3-27_18-33-45.png
(Note the arrows to the left of each element)

when I click on each element the inspector show the following :

6980735--823598--upload_2021-3-27_18-39-40.png
(note the arrows to the left of each Answer)

When I click on the Answers the inspector show the following:


(I have added the value 4 next to each Answer in the inspector)

Just to recap on my question :

How can I change the QnA size value (currently 1, as shown above) and the Answers Size value (currently 4, as shown above) in my ListManger script via an inputfield.text field.

Note that the structure of the List QnA(as shown above) should stay the same as the correct answer value is connected to the answers and the answers is connected to the question.

I’m not really sure I understand the question. Do you mean you want the size of the QnA list and the size of each Answer array to be the same value, and to be able to set that value from a custom text input in the inspector?
I.E: If you have 4 questions, each question has 4 answers, and if you have 10 questions, each question has 10 answers?

Or perhaps do you mean you want to globally set the number of questions and answers separately via two custom text inputs?
I.E: One text input sets the size of the QnA list, and the other sets the size of all the Answer arrays in each QnA list element.

I don’t get what I’m supposed to be noting about the drop-down arrows. Do you instead mean you want to not hide the questions/answers in a drop-down and just display them regularly without hiding them?

Thanks for your reply.
If I have 4 questions each question should have an options to set how many answers that questions should have.

So if i have 10 questions I should be able to change the answer size to say 4 and each of the 10 questions should have 4 answers like in a multichoice quiz.

With this in mind I want to change the QnA size that will determine how many questions there will be and then I want to change the answer size that will determine how many answers each question will have.

Both the QnA size value and the answer size value I want to change via a inputfield.text field.

Hope this make more sense.

I think I solved the problem.

This is my code for the serializable list called QnA


[Serializable]
private class QnA
{
public string question;
public string[ ] answers;
public int correctAnswer;
}```

Then I made a serializedField like this

[SerializeField] private QnA[ ] qnaArray;

In my Start function in just did the following

```public void Start()
{
qnaArray = new QnA[newsize];

}```

So when I run the application the QnA size automatically change to the newsize int value. I will now continue to try and change the answer value through the code and implement the inputfield to replace the newsize int.

Thanks for everyone's assistance. It is much appreciated.

Next question is how do I access the public string[ ] answer in the serializable class to change its value.