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); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter