Click here to Skip to main content
15,921,276 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class QuizManager : MonoBehaviour
    public List<QuestionAndAnswers> QnA;
    public GameObject[] options;
    public int currentQuestion;

    public Text QuestionTxt;

    private void Start()

    void SetAnswers()
        for(int i = 0; i< options.Length; i++)
            options[i].GetComponet<AnswerScript>.isCorrect = false;
             <Text>().text = QnA[currentQuestion].Answer[i];
            if(QnA[currentQuestion].CorrectAnswer == i+1)
                options[i].GetComponet<AnswerScript>.isCorrect = true;

    void generateQuestion()
        currentQuestion = Random.Range(0,QnA.Count);

        QuestionTxt.text= QnA[currentQuestion].Question;

What I have tried:

I am trying to make a Quiz.
I am watching How to make a Quiz Game with Multiple Choices in Unity - YouTube[^]

I got the following error:

Assets\QuizManager.cs(11,12): error CS0246: The type or namespace name 'Text' could not be found (are you missing a using directive or an assembly reference?)

Please help me!
Updated 13-Sep-23 4:34am

The error message tells you exactly what is wrong. It can't find a thing called 'Text'. It even asks if you're missing a using directive. The video you referenced even shows the using statement you need being added when the object is added on the screen.

The 'Text' object is under UnityEngine.UI. You need to add a using statement for it.
Share this answer
Add "Using UnityEngine.UI" and it resolves the issue. Hope you have the correct version of UnityEngine refrence.

Link :
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900