Active game object by button

Hi,

I have this code on button:

using UnityEngine;
using System.Collections;

public class button : MonoBehaviour {

	public GameObject object1;

	void Start () 
	{
		GameObject.Find("object1").SetActive(true);
	}
	
	// Update is called once per frame
	void OnMouseDown () 
	{
		GameObject.Find("object1").SetActive(false);
	}
}

and i want disable or enable some game object in game which a select, but it doesn’t work if i click on button. I am new in unity and C# so maybe i make big wrong.
Thanks for answers.

the game object to which the script containing onMouseDown is attached , needs a collider .

void OnMouseDown () 
    {
       gameObject.SetActive(false);
    }

this should do it.

This should work the above answer has a small mistake.

void OnMouseDown ()
{
   object1.SetActive(!object1.activeSelf);
}

This code will enable the gameobject you attaced if it was already disable or it will enable the gameobject you attached if it was disable. If you simply want it to be disable on button click use the one below.

void OnMouseDown ()
{
    object1.SetActive(false);
}