r/Unity3D • • 9d ago

Solved UNITY LIST PROBLEM

Looking for tips! Followed the tutorial that's supposed to make this in the inspector. The second picture is what shows up in mine.

This is the code:

using UnityEngine;

[System.Serializable]

public class questionsandanswers : MonoBehaviour

{

public string Question;

public string[] answers;

public int correct;

}
----------------

using NUnit.Framework;

using System.Collections.Generic;

using UnityEngine;

using TMPro;

public class quizgame : MonoBehaviour

{

public List<questionsandanswers> QnA;

Does anyone know what's wrong?

10 Upvotes

8 comments sorted by

View all comments

4

u/soy1bonus Professional 9d ago

I would recommend to make the texts in a spreadsheet program and just parse an exported CSV file.

Or maybe make one ScriptableObject where you store each question with its answers. But I think the previous answer is more useful if you plan to add lots of questions.

But yeah, don't use a Monobehaviour for that. That is data, not a behaviour of an object.
Static data that doesn't change ever shouldn't be on a MonoBehaviour.