I have to two UI text . One timer script and one score script .The scenes won’t switch when the countdown timer reaches zero. Will dont destroy on load work if I a call that function in the score script change the scene ? I have points set to 50 . The scene will only change if the score is below 50 and the timer reach zero. Here are my script.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
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.score > 0)
{
SceneManager.LoadScene("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);
}
}
What do you mean by preload scene . Where at on the singleton script would I call the DonDestroyOnLoad function ?
– importguru88