I don’t have any errors . The problem I am having is the scenes with not load when the countdown timer reaches zero and number has to be below the number I got set for . So if the number is higher than number I set for scene changes but the thing is the timer gotta be at zero. I got two UI text as you can see . I got everything in my build settings and I add don’t destroy on load in the awake function. I am accessing the score script and clock script from the test script. I did a gameobject tag for the score , because I am accessing the score script within the same object . The scene is still not changing . I don’t know what is going on here are my scripts :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Test : MonoBehaviour {
private MyClockScript myClock;
public GameObject Score;
private ScoreManagerScript scoremanager;
void Awake () {
myClock = GetComponent();
GameObject Score = GameObject.FindWithTag(“Tip”);
scoremanager = GetComponent();
}
void Update ()
{
if (myClock.m_leftTime < 0 && 0 < ScoreManagerScript.score)
{
SceneManager.LoadScene("j");
}
}
}
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class MyClockScript : MonoBehaviour
{
public int Minutes = 0;
public int Seconds = 0;
private Text m_text;
public float m_leftTime;
public void Awake()
{
m_text = GetComponent<Text>();
m_leftTime = GetInitialTime();
DontDestroyOnLoad(gameObject);
}
public void Update()
{
if (m_leftTime > 0f)
{
// Update countdown clock
m_leftTime -= Time.deltaTime;
Minutes = GetLeftMinutes();
Seconds = GetLeftSeconds();
// Show current clock
if (m_leftTime > 0f)
{
m_text.text = "Time : " + Minutes + ":" + Seconds.ToString("00");
}
else
{
// The countdown clock has finished
m_text.text = "Time : 0:00";
}
}
}
private float GetInitialTime()
{
return Minutes * 60f + Seconds;
}
private int GetLeftMinutes()
{
return Mathf.FloorToInt(m_leftTime / 60f);
}
private int GetLeftSeconds()
{
return Mathf.FloorToInt(m_leftTime % 60f);
}
}
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class ScoreManagerScript : MonoBehaviour
{
public static int score;
private Text text;
void Awake()
{
text = GetComponent <Text> ();
score = 0;
DontDestroyOnLoad(gameObject);
}
void Update()
{
text.text = "Score: " + score;
Debug.Log("Score: " + score);
}
}