Hi!
I keep having issues with TextMeshProUGUI. I have set it up correctly:
public class MainCode4 : MonoBehaviour
{
public TextMeshProUGUI displaytext;
private string test1;
void Start(){
test1 = "say / type";
displaytext.text = test1;
Up until here everything works; the TextMeshProUGUi is “say / type”.
However, I get an error immediately when I run program and try to display it anything else, like a .name.
For example:
if (Physics.Raycast(transform.position, fwd, 100)){
Transform objectHit = hit.transform;
test1 = objectHit.name;
displaytext.text = test1;
Returns: “TextMesh Pro NullReferenceException: Object reference not set to an instance of an object”.
The text mesh is added correctly in the inspector (of course as the first code works, displaying everything correctly).
Help is appreciated!