Mouse Active Once Canvas Active, Help!

Hello, I am trying to make a script so the mouse is active once a canvas is active in game. I am unsure on how to make it work and what I currently have throws errors. Here is my script

using UnityEngine;
using System.Collections;
public class MouseGone : MonoBehaviour
{
	// Use this for initialization
	void Start()
	{
		//Set Cursor to not be invisible
		Cursor.visible = false;
		if (Canvas.gameObject = false);
	}

	void update ()
	{
	//Set Cursor to be visible
	Cursor.visible = true;
	if (Canvas.gameObject = true);

}
}

If you can help me in anyway that will be greatly appericated!

So several things.

-update needs to be capitalized for the built in function.
-if statements come before the result you want to execute.
-Canvas.gameObject is invalid. You need to reference a specific canvas object
-gameObject isn’t a boolean, so you can’t compare that to true or false.

Also if I understand what you’re trying to do, you should have everything in the Update function. So you should have:

using UnityEngine;
 using System.Collections;
 public class MouseGone : MonoBehaviour
 {
     Canvas canvas; //assign this by dragging your canvas to it in the inspector


     void Start()
     {
           Cursor.visible = true;
     }
 
     void Update ()
     {
         Cursor.visible = (canvas.gameObject.active);
      }
 }

Hope that helps