How to enable and disable a canvas window by scripting

Hi,

I want to ask a question about UGUI. that i want to add a canvas window with four buttons at run time. how to do it please help.
Please help me

The above answer is correct if you want to disable the gameObject itself. To disable the Canvas component you can use this:

CanvasObject.GetComponent<Canvas> ().enabled = false;

This avoids null object errors.

Just like you disable , any gameobject? make a variable , assign the Canvas then simply ,

void DisableCanvas() {
     CanvasObject.SetActive(false);
}