I had made some changes on my script and I gotten one error. I trying to access the score script along with another script . Here is my scripts:
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class Game : MonoBehaviour {
private MyClockScript myClock;
void Start () {
myClock = GetComponent();
}
// Update is called once per frame
void Update () {
if (myClock.m_leftTime <= 0 || GameManagerSingleton.instance.score > 50)
{
SceneManager.LoadScene("I");
}
}
}
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class GameManagerSingleton : MonoBehaviour
{
public static GameManagerSingleton instance = null;
public static int score;
private Text text;
void Awake()
{
text = GetComponent <Text> ();
score = 0;
if (instance != null && instance != this)
Destroy(gameObject); // Ensures that there aren't multiple Singletons
instance = this;
}
void Update()
{
text.text = "Score: " + score;
Debug.Log("Score: " + score);
}
}