I want to enable my panel gameobject when I interact with something but it doesn’t get enabled when I tell it to do so. I referenced it in the inspector and the console doesn’t show any errors. I’m calling the SetDetailText function in another script. And what’s weird is that the text does get updated AFTER I stop the game.
Here is my code:
public class GameManager : MonoBehaviour
{
//Objects
public GameObject statusPanel;
public Text statusText;
//Private
float textCooldownTime;
void Start()
{
statusPanel.SetActive(false);
textCooldownTime = 2.0f;
}
void Update()
{
if (statusPanel.activeSelf)
{
textCooldownTime -= Time.deltaTime;
if (textCooldownTime < 0)
{
statusPanel.SetActive(false);
textCooldownTime = 2.0f;
}
}
}
public void SetDetailText(string details)
{
statusPanel.SetActive(true);
statusText.text = details;
}
}