Button | Unit 9

PHOTO EMBED

Tue May 17 2022 21:20:00 GMT+0000 (Coordinated Universal Time)

Saved by @BiscuitTinx #c#

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

public class ButtonScript : MonoBehaviour
{
    public bool isCorrect;

    [SerializeField] Text Correct;
    [SerializeField] Text Wrong;

    RandomNumber rn;
    private void Awake()
    {
        rn = GameObject.Find("chalkboardfbx").GetComponent<RandomNumber>();
    }

    public void OnClick()
    {
        if (isCorrect)
        {
            Debug.Log("Correct");
            Correct.gameObject.SetActive(true);
        }
        else if (!isCorrect)
        {
            Debug.Log("Incorrect");
            Wrong.gameObject.SetActive(true);
        }
        StartCoroutine(disableText());
        rn.rngQuestion();
        rn.rngButtons();
    }

    IEnumerator disableText()
    {
        yield return new WaitForSeconds(2);
        Correct.gameObject.SetActive(false);
        Wrong.gameObject.SetActive(false);
    }
}
content_copyCOPY