- Home /
Question by
importguru88 · Jun 23, 2016 at 05:15 PM ·
uigameobjecttextcanvaschildren
How do I carry over ui text to the next by obtaining the gameobject children
I need to switch scenes and it's not allowing me to do that. I accessing two script from this script class test. I just need help with one of the text scripts :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Test : MonoBehaviour {
private MyClockScript myClock;
public GameObject Score;
public GameObject Text;
private ScoreManagerScript scoremanager;
void Awake () {
myClock = GetComponent<MyClockScript>();
scoremanager = GetComponent<ScoreManagerScript>();
Score = GameObject.Find("Tip");
}
void Update ()
{
if (myClock.m_leftTime <= 0 && 0 <= ScoreManagerScript.score)
{
SceneManager.LoadScene("new");
}
}
}
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(transform.gameObject);
}
void Update()
{
text.text = "Score: " + score;
Debug.Log("Score: " + score);
}
}
Comment
Your answer
Follow this Question
Related Questions
Canvas shrinks over time 0 Answers
Masking GameObject in Canvas 1 Answer
Unity 5 UI GUI Text Canvas Screen Resolution Adaption Problem 2 Answers
Adding a string to grid layout group 1 Answer
rendering panel w/children 0 Answers