# Reactivate Game Object

**URL:** https://discussions.unity.com/t/reactivate-game-object/592242
**Category:** Scripting
**Tags:** Scripting
**Created:** [August 4, 2015, 7:38pm UTC](https://discussions.unity.com/t/reactivate-game-object/592242 "2015-08-04T19:38:51Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Vindatra14](https://avatars.discourse-cdn.com/v4/letter/v/d6d6ee/32.png) [@Vindatra14](https://discussions.unity.com/u/Vindatra14)
#### Post date: [August 4, 2015, 7:38pm UTC](https://discussions.unity.com/t/reactivate-game-object/592242/1 "2015-08-04T19:38:51Z")

</div>

I have this button to disable my gameobject, but I want to activate it again when I click on another button. When I write the same code GameObject.Find (“body maker”).SetActive (true) it can’t activate back and still disable. How can I make this button enable again.

```csharp
public class TakePhoto : MonoBehaviour{   
    void OnMouseDown()
    {
        GameObject.Find ("body maker").SetActive (false);
    }
}

```

---

<div class="post-metadata">

### Author: ![Daso1970](https://avatars.discourse-cdn.com/v4/letter/d/8dc957/32.png) [@Daso1970](https://discussions.unity.com/u/Daso1970)
#### Post date: [August 4, 2015, 7:49pm UTC](https://discussions.unity.com/t/reactivate-game-object/592242/2 "2015-08-04T19:49:51Z")

</div>

The problem is probably that once you deactivate the GameObject it will stop receiving messages such as OnMouseDown.

You need to either move the deactivation/activation code somewhere else or instead of using SetActive you set a variable to true/false upon OnMouseDown which is checked everywhere in your components for that GameObject to determine if it is active or not.

---

<div class="post-metadata">

### Author: ![Vindatra14](https://avatars.discourse-cdn.com/v4/letter/v/d6d6ee/32.png) [@Vindatra14](https://discussions.unity.com/u/Vindatra14)
#### Post date: [August 4, 2015, 7:52pm UTC](https://discussions.unity.com/t/reactivate-game-object/592242/3 "2015-08-04T19:52:42Z")

</div>

hhmm I mean like this I have button a b and c. First onmousedown I disable button c, but I want to make if I onmousedown button b that button c become active again, something like that

---

<div class="post-metadata">

### Author: ![DonLoquacious](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/donloquacious/32/333500_2.png) [@DonLoquacious](https://discussions.unity.com/u/DonLoquacious)
#### Post date: [August 4, 2015, 7:56pm UTC](https://discussions.unity.com/t/reactivate-game-object/592242/4 "2015-08-04T19:56:42Z")

</div>

You need to save the button reference to a class variable on Awake or Start, for both scripts (you can use Find while it’s still enabled). Alternatively, you can make public class members on both and just drag the reference into it in the inspector (then whether it starts enabled or not is irrelevant.

You can re-enable GameObjects easily as long as you have a reference to them, but you can’t use Find or FindWithTag to locate disabled GameObjects, so you need to have the reference beforehand. Get it?

---

<div class="post-metadata">

### Author: ![Vindatra14](https://avatars.discourse-cdn.com/v4/letter/v/d6d6ee/32.png) [@Vindatra14](https://discussions.unity.com/u/Vindatra14)
#### Post date: [August 4, 2015, 8:00pm UTC](https://discussions.unity.com/t/reactivate-game-object/592242/5 "2015-08-04T20:00:20Z")

</div>

hhmm excuse me Lysander I understand what u mean, but I’m still new at unity and still learn it. How I reference that GameObject can u write some script or code with explanation ?

---

<div class="post-metadata">

### Author: ![Daso1970](https://avatars.discourse-cdn.com/v4/letter/d/8dc957/32.png) [@Daso1970](https://discussions.unity.com/u/Daso1970)
#### Post date: [August 4, 2015, 8:07pm UTC](https://discussions.unity.com/t/reactivate-game-object/592242/6 "2015-08-04T20:07:52Z")

</div>

hhmm he means that GameObject.Find (“body maker”) won’t find “body maker” if it is disabled.

So put variable = GameObject.Find (“body maker”) into a Start method so you will have a reference to it. Then you perform variable.SetActive (false); instead of using Find in your OnMouseDown methods.

```csharp
public class TakePhoto : MonoBehaviour{
  GameObject variable;

  void Start()
  {
  variable = GameObject.Find ("body maker");
  }
   
  void OnMouseDown()
  {
  variable.SetActive (false);
  }
}

```

---

<div class="post-metadata">

### Author: ![Vindatra14](https://avatars.discourse-cdn.com/v4/letter/v/d6d6ee/32.png) [@Vindatra14](https://discussions.unity.com/u/Vindatra14)
#### Post date: [August 4, 2015, 8:19pm UTC](https://discussions.unity.com/t/reactivate-game-object/592242/7 "2015-08-04T20:19:16Z")

</div>

How about like this I have 3 child gameobject a b and c and my parent is GameObject. So GameObject include a b and c, then I want to make button a to disable button c and button b to disable button b, How I check if that button is click ??

---

<div class="post-metadata">

### Author: ![Vindatra14](https://avatars.discourse-cdn.com/v4/letter/v/d6d6ee/32.png) [@Vindatra14](https://discussions.unity.com/u/Vindatra14)
#### Post date: [August 5, 2015, 12:17am UTC](https://discussions.unity.com/t/reactivate-game-object/592242/8 "2015-08-05T00:17:48Z")

</div>

any1 can help me with this, I’m gonna start some conversation if any1 want to help me. Maybe many question because still new to Unity
