Thank you for the answers guys!
I still havn’t quite found a solution though…
I’m not very experienced with using lists, so I got a few issues…
Currently I’ve made a travia-question system that works like this:
Each question has three possible answers. Each answer has a script like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Answer1Data
{
public string answer1Text;
public bool isCorrect;
}
Each question then have this script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class QuestionData
{
public string questionText;
public Answer1Data answer1;
public Answer2Data answer2;
public Answer3Data answer3;
}
I then have this script to define stuff like timelimit, points won or lost and so on.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class RoundData
{
public int timeLimitInSeconds;
public int hiddenTimeLimitInSeconds;
public int pointsAddedForFirstCorrectAnswer;
public int pointsAddedForSecondCorrectAnswer;
public int pointsSustractedForWrongAnswer;
public QuestionData[] questions;
}
I then finally have a script that tie all the scripts above together, so that the information can be decided from the inspector:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class DataController : MonoBehaviour
{
public static DataController instance;
void Awake()
{
if (instance == null)
{
instance = this;
DontDestroyOnLoad(gameObject);
}
else
{
Destroy(gameObject);
}
}
public RoundData[] allRoundData;
void Start()
{
SceneManager.LoadScene("MenuScreen");
}
public RoundData GetCurrentRoundData()
{
return allRoundData[0];
}
}
I made the scripts this way, to make the overview in the inspector look somewhat neat, since I won’t be the one writing all the questions myself.
As mentioned, I am by no means a good programmer, so I am sure that this is a very cluncky way to do it and that it probably could be done from a single script, but I just don’t know how.
But in either case…
How do I turn something like this into lists instead of arrays?
As mentioned I only really have experience with arrays, and when I try to figure out how to make the same thing with lists instead I keep getting various scripting errors.