I’m using GetComponentInChildren for 2 different TextMeshProUGUI but as soon as I try to play it changes both into the same one. What I’m trying to make is a script to show both time and score.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class Scores : MonoBehaviour
{
public TextMeshProUGUI TimeCounter;
public TextMeshProUGUI ScoreCounter;
void Awake(){
TimeCounter=GetComponentInChildren<TextMeshProUGUI>();
ScoreCounter=GetComponentInChildren<TextMeshProUGUI>();
}
public void TheTime(float H){
TimeCounter.text=H.ToString();
}
public void TheScore(int P){
ScoreCounter.text="Score: "+P;
}
}
Any hints? I was getting NullReferenceException when trying to change their texts with GetComponent instead of GetComponentInChildren.