This is what I was suggested to use to display text from code (so that it could change according to a variable) onto a per-existing GUI text Object, it just doesn’t seem to be working?
I just added the Text object as a data member to my code and dropped it in.
Also:
gameObject.GetComponentInChildren();
you’re getting a null reference exception at the bottom… what is that referring to?
Solved Thank you
Do you mind sharing what was the problem and how you solved it?
I used this instead
You must access to the GameObject first, have a reference to an GameObject.
i have the same issue and need help to fix it this is my script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Souls : MonoBehaviour
public static int SoulCount;
public GameObject SoulDisplay;
public int InternalSoul;
void Update ()
InternalSoul = SoulCount;
SoulDisplay.GetComponent().text = "Souls: " + InternalSoul;
}
}
if anyone could help it would be great