Hi im 100% new to coding I was following this tutorial for a quiz
and I’m done but it keeps giving me this warning in monodevelop "Field "__ " is never assigned to, and will always have it’s default value null. the problem is[SerializeField]
private Text factText;
to
[SerializeField]
private Animator animator;
heres the code (c#)
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.SceneManagement;
public class GameManager1 : MonoBehaviour {
public Questions[] questions;
private static List<Questions> unansweredQuestions;
private Questions currentQuestion;
[SerializeField]
private Text factText;
[SerializeField]
private Text trueAnswerText;
[SerializeField]
private Text falseAnswerText;
[SerializeField]
private Animator animator;
[SerializeField]
private float timeBetweenQuestions = 1f;
void start ()
{
if (unansweredQuestions == null || unansweredQuestions.Count == 0)
{
unansweredQuestions = questions.ToList<Questions>();
}
SetCurrentQuestion();
}
void SetCurrentQuestion ()
{
int randomQuestionIndex = Random.Range(0, unansweredQuestions.Count);
currentQuestion = unansweredQuestions[randomQuestionIndex];
factText.text = currentQuestion.fact;
if (currentQuestion.isTrue)
{
trueAnswerText.text = "CORRECT";
falseAnswerText.text = "WRONG";
} else
{
trueAnswerText.text = "WRONG";
falseAnswerText.text = "CORRECT";
}
}
IEnumerator TransitionToNextQuestion ()
{
unansweredQuestions.Remove(currentQuestion);
yield return new WaitForSeconds(timeBetweenQuestions);
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
public void UserSelectTrue ()
{
animator.SetTrigger("True");
if (currentQuestion.isTrue)
{
Debug.Log("CORRECT!");
} else
{
Debug.Log("WRONG!");
}
StartCoroutine(TransitionToNextQuestion());
}