I called an don’tdestroyOnLoad function on two scripts and it doesn’t seem to work . I need to carry the ui text over to the next scene. I don’t have any errors . I also tried to fix this problem by adding a gameobject tag in the awake function on the test script. I don’t know what to do from here. I need help .
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 ScoreManagerScript : MonoBehaviour
{
public static int score;
private Text text;
void Awake ()
{
text = GetComponent ();
score = 0;
DontDestroyOnLoad(gameObject);
}
void Update()
{
text.text = "Score: " + score;
Debug.Log("Score: " + score);
}