I have a tutorial program for children. The point is this: a random example is generated from the numbers a and b and a random sign is generated. Everything works fine, but I can't make the counter of correct answers (the prav variable). The script assigned to the buttons (otvet1, otvet2, otvet3) and example (zadacha), but I get some sort of nonsense. PLEASE HELP ALREADY HEAD IS ON 2 DAY THE SIT DOES NOT EXIT
using UnityEngine; using UnityEngine.UI; using System.Collections; public class GameControl : MonoBehaviour { public int a, znak, b, c, count, otvet, randomtext, tochnosykablyat; static int prav=0; public Text otvet1; public Text otvet2; public Text otvet3; public Text zadacha; public Text Count; void Start() { Yravnenie(); } void Yravnenie() { count++; //if(count<21) //{ Application.Quit(); Count.text = count+"/20"; } a = Random.Range(1, 21); b = Random.RandomRange(1, 21); znak = Random.RandomRange(1, 3); if (znak == 1) { zadacha.text = a + " + " + b + " = ?"; otvet = a + b; } if (znak == 2 && a >= b) { zadacha.text = a + " - " + b + " = ?"; otvet = a - b; } if (znak == 2 && a < b) { zadacha.text = a + " + " + b + " = ?"; otvet = a + b; } randomtext = Random.RandomRange(1, 4); tochnosykablyat = randomtext; if (randomtext == 1) otvet1.text = otvet.ToString(); if (randomtext == 2) otvet2.text = otvet.ToString(); if (randomtext == 3) otvet3.text = otvet.ToString(); a = Random.Range(2, 16); if (a == otvet) a--; if (randomtext == 1) otvet3.text = a.ToString(); if (randomtext == 2) otvet1.text = a.ToString(); if (randomtext == 3) otvet2.text = a.ToString(); b = Random.RandomRange(17, 31); if (b == otvet) b--; if (randomtext == 1) otvet2.text = b.ToString(); if (randomtext == 2) otvet3.text = b.ToString(); if (randomtext == 3) otvet1.text = b.ToString(); } void OnMouseUpAsButton() { if (gameObject.name == "otvet1" && tochnosykablyat == 1) { prav = prav + 1; Yravnenie(); } if (gameObject.name == "otvet2" && tochnosykablyat == 2) { prav = prav + 1; Yravnenie(); } if (gameObject.name == "otvet3" && tochnosykablyat == 3) { prav = prav + 1; Yravnenie(); } Count.text = prav.ToString(); } }