using System; using System.Collections; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.Serialization; using UnityEngine.UI; public class QuizPopUp : Menu { [Header("Questions")] [SerializeField] TextMeshProUGUI questionText; [SerializeField] QuestionSO currentQuestion; [Header("Answers")] [SerializeField] private Sprite trueAnswerSprite; [SerializeField] private Sprite falseAnswerSprite; [SerializeField] GameObject[] answerButtons; int correctAnswerIndex; bool hasAnsweredEarly; [Header("Timer")] [SerializeField] Image timerImage; public GameManager gameManager; public DataManager dataManager; public bool isComplete = false; bool isGameOver = false; //======================== [SerializeField] float timeToCompleteQuestion = 30f; [SerializeField] float timeToShowCorrectAnswer = 10f; public bool loadNextQuestion; public float fillFraction; public bool isAnsweringQuestion; float timerValue; private void OnEnable() { gameManager = FindObjectOfType(); dataManager = FindObjectOfType(); if (gameManager == null) return; currentQuestion = gameManager.currentQuestion; correctAnswerIndex = currentQuestion.answerIndex; timerValue = timeToCompleteQuestion; isAnsweringQuestion = true; fillFraction = 1f; loadNextQuestion = false; hasAnsweredEarly = false; isComplete = false; SetButtonState(true); DisplayQuestion(); } private void OnDisable() { // Reset question and timer state isAnsweringQuestion = false; hasAnsweredEarly = false; loadNextQuestion = false; isComplete = false; fillFraction = 1f; timerValue = 0f; // Reset question text questionText.text = ""; // Reset all button colors and enable them for (int i = 0; i < answerButtons.Length; i++) { Button button = answerButtons[i].GetComponent