Trying to Invoke method: QuizManager.SelectedQuestion couldn't be called. Error in unity.

Joined
Nov 24, 2023
Messages
1
Reaction score
0
Pls help this is for an important project. Thanks!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class QuizManager : MonoBehaviour
{
[SerializeField] private QuizUI quizUI;
[SerializeField] private QuizDataScriptable quizData;

private List<Question> questions;
private Question selectedQuestion;
// Start is called before the first frame update
void Start()
{
questions = quizData.questions;

SelectQuestion();
}

void SelectQuestion()
{
int val = Random.Range(0, questions.Count);
selectedQuestion = questions[val];

quizUI.SetQuestion(selectedQuestion);
}

public bool Answer(string answered)
{
bool correctAns = false;

if(answered == selectedQuestion.correctAns)
{
//Yes
correctAns = true;
}
else
{
//No
}

Invoke("SelectedQuestion", 0.4f);

return correctAns;
}
}

[System.Serializable]
public class Question
{
public string questionInfo;
public QuestionType questionType;
public Sprite qustionImg;
public AudioClip qustionClip;
public UnityEngine.Video.VideoClip qustionVideo;
public List<string> options;
public string correctAns;
}

[System.Serializable]
public enum QuestionType
{
TEXT,
IMAGE,
VIDEO,
AUDIO
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,818
Messages
2,569,727
Members
45,661
Latest member
NadineBour

Latest Threads

Top