Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- [RequireComponent(typeof(AudioSource))]
- public class Reader : MonoBehaviour
- {
- private GameManager gm;
- public Text text;
- public Question question;
- private AudioSource _audio;
- private void Start()
- {
- gm = GameObject.FindGameObjectWithTag("GameManager").GetComponent<GameManager>();
- _audio = GetComponent<AudioSource>();
- }
- private void Update()
- {
- if (question != null)
- {
- text.text = question.answer.ToString();
- _audio.PlayOneShot(gm.correctAnswer.GetComponent<AudioSource>().Play());
- }
- }
- public void CheckAnswer()
- {
- if (transform.gameObject != gm.correctAnswer.transform.gameObject)
- {
- transform.GetComponent<Image>().color = Color.red;
- }
- gm.correctAnswer.GetComponent<Image>().color = Color.green;
- foreach (Button btn in gm.options)
- {
- btn.GetComponent<Button>().interactable = false;
- }
- gm.correctAnswer.GetComponent<Button>().interactable = false;
- StartCoroutine(gm.NewRound());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement