Toggling UI Panel is not Visible

Hello,

I’m trying to toggle UI element visibility. I have a Canvas → Panel → Text heirarchy. I added another object in the root of my project called SelectController. I attached the following script to SelectController.

public class SelectController : MonoBehaviour
{
	public GameObject panel;

	void Start ()
	{
		panel.SetActive (false);
	}
	
	void Update ()
	{
		if (Input.GetMouseButtonDown (0)) {
			bool temp = panel.activeSelf;
			panel.SetActive (!temp);
		}
	}
}

When I run my game the panel is disabled. When I click the mouse I can see in Heirarchy that the Panel and Text objects both successfully toggle between enabled, but nothing is viewable. If I comment out the code in Start() everything works as expected except the panel starts enabled, which I cannot have. Am I completely missing something here? I’ve checked all the alpha layers and everything is correct between toggles.

I had this problem too, Just leave the panel activated and disable it on start after few frames. It helped me.