Не изменяется значение bool переменной
Во время игры в Unity хотим сделать: Когда score = 1 появлялся вопрос, VPR.active = true; но код ничего не делает, а если поставить false, то окно спокойно пропадает. В чём наша ошибка ?
Внизу привожу три класса которые используются
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class GameControl : MonoBehaviour {
public static GameControl instance;
public GameObject gameOverText;
public Text scoreText;
public bool gameOver = false;
public float scrollSpeed = -3f;
public static int score = 0;
// Use this for initialization
void Awake ()
{
if (instance == null) {
instance = this;
} else if (instance != this)
{
Destroy (gameObject);
}
}
// Update is called once per frame
void Update()
{
if (gameOver == true && Input.GetMouseButtonDown (1))
{
SceneManager.LoadScene (SceneManager.GetActiveScene ().buildIndex);
}
}
public void BirdScored()
{
if (gameOver)
{
return;
}
score++;
scoreText.text = "Score: " + score.ToString ();
}
public void BirdDied()
{
gameOverText.SetActive (true);
gameOver = true;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Taks : MonoBehaviour {
public TextAsset All;
string Text;
public string TasK;
public string Answers;
public Text Tesk;
public Text a1;
public Text a2;
public Text a3;
public Text a4;
public string True;
// Use this for initialization
void Start ()
{
Text = All.text;
string[] s = Text.Split('/');
TasK = s [0];
Answers = s [1];
True = s [2];
Tesk.text = TasK;
string[] A = Answers.Split (';');
a1.text = A [0];
a2.text = A [1];
a3.text = A [2];
a4.text = A [3];
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BTN_TXT : MonoBehaviour {
public GameObject VPR;
public Color gr;
public Color fl;
public Image th;
public Text t;
public Taks task;
// Use this for initialization
public void Start ()
{
}
// Update is called once per frame
public void Check ()
{
if (t.text == task.True) {
th.color = gr;
StartCoroutine (Wait ());
} else {
th.color = fl;
StartCoroutine (Wait ());
GameControl.instance.BirdDied ();
}
}
IEnumerator Wait()
{
yield return new WaitForSeconds (2);
VPR.active = false;
}
void Update(){
if (GameControl.score == 1) {
VPR.active = true;
}
}
}