UIText Prefab not reloading after switching scenes

Hello, I developed a system where when I click on a button (circle button prefab) it will display a line of text from the UIText Prefab in the holotoolkit, and then when I click on the button a second time, the text is deleted. However, I recently included a second scene and after visiting the second screen, the button no longer displays the text? Have any of y'all run into this before?

Code:
public class TextAppear : MonoBehaviour, IInputClickHandler {
public GameObject TextPrefab;
bool NumberPressed = false;
GameObject TextPrefabClone;

public void OnInputClicked(InputClickedEventData eventData)
{
    if (NumberPressed == false){
        NumberPressed = true;
        TextPrefab.SetActive(true);
        TextPrefabClone = Instantiate(TextPrefab);
        TextPrefabClone.SetActive(true);
        var position = gameObject.transform.position;
        TextPrefabClone.gameObject.transform.position = new Vector3(position.x, position.y + .1f, position.z);
    }
   else
    {
        NumberPressed = false;
        Destroy(TextPrefabClone);

}

Thanks Again! and sorry the code is kinda messy right now, I was playing around with the set Active settings to see if I could get it to work.

Sign In or Register to comment.