Quantcast
Channel: Questions in topic: "warnings"
Viewing all articles
Browse latest Browse all 187

"Field " " is never assigned to, and will always have it's default value null"

$
0
0
Hi im 100% new to coding I was following this tutorial for a quiz https://www.youtube.com/watch?v=zLnnpUsxu0U 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 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(); } 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()); }

Viewing all articles
Browse latest Browse all 187

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>