How to activate a gameobject via scripting ???

In my game I need to deactivate a gameobject when I click it occurs and make it activated in all other time.I use the following code.

public GameObject me;

	void Update ()
	{ = true;


	void OnMouseDown()
	{ = false;

I am attaching this script to the gameobject which must be deactivated.But I am able to deactivate when I click it but it is not at all re-activating.
Is there anything I have missed out??
I have also used,gameobject.SetActive().Nothing worked.

You are disabling the object, so also the game component, the script itself, so it cannot execute anything anymore.

Instead of de-activate the object, you want to de-activate just something like the collider and/or the rendering. Try something like this.

void OnMouseDown()

This lets you disable the rendering of the object.(Instead of disabling the whole object)
This code might not work because I mainly use UnityScript but hopefully this can help you out abit

  • Doesn’t Void Update() repeat the command each second? it means that, when deactivating. The object will immediatly be enabled again.

I guess this can be solved by using if statements.

after the object has been deactivated the Update () function does not get called any more.

the handling of the reactivation will need to be handled be another object that preferable handles most of the proccess.