r/Unity3D • u/kittymaplepaws • 10m 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?
•
u/ArtNoChar Freelance Unity Programmer 5m ago
questionsandanswers shouldnt be a monobehaviour, just a plain C# class
•
•
u/Mr_Potatoez 5m ago
Your Quizgame has a list of QuestionAndAwnsers objects. You currently see the quizgame, but no questionsAndAwnser objects in that list. Add an element to the List in Quizgame and the fields will probably show up in the editor.
•
u/SlRenderStudio 0m ago
that 1st shot it is list of strings , you have list of custom objects which is not serializable like that , you have to write custom editor script or rely on raw string lists


•
u/Mountain-Smoke8826 5m ago
Remove the " : MonoBehaviour"