I want to disable the Question Prefab so that when it is clicked the Prefab behind it will be shown:

I am using Unity 5.3.5 and C#.

  • \$\begingroup\$ Do you have a correct ollider on the object that also has your script? \$\endgroup\$
    – M156
    Commented Dec 24, 2016 at 12:46
  • \$\begingroup\$ I have a Box Collider 2D on the GameObject \$\endgroup\$
    – Paul
    Commented Dec 24, 2016 at 12:55
  • \$\begingroup\$ I think this code disables all the objects that contains this script. Can you please elaborate what you actually want?? \$\endgroup\$ Commented Dec 25, 2016 at 8:36
  • \$\begingroup\$ I want that when i press on one of the question prefabs the image that there is behind it will be shown. Thanks \$\endgroup\$
    – Paul
    Commented Dec 26, 2016 at 17:53

1 Answer 1


I created a new gameObject and added this script:

Why did you created a new gameObject when you wanted to disable the prefab clones?.

There's nothing wrong with the given code. You should put the script on your Prefab.

If it still doesn't work. You can use EventSystems to get the Game Object that is currently selected and deactivate it.

Check this link for how to use Event Systems.

  • \$\begingroup\$ Ok thanks i managed to do it... Now how can i match a pair of cards. I have a prefabs folder with 18 images which are duplicated in the same folder, so the total cards is 36.. How can i make unity identify that 2 cards are the same. Thanks \$\endgroup\$
    – Paul
    Commented Dec 27, 2016 at 9:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .