0
\$\begingroup\$

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#.

\$\endgroup\$
  • \$\begingroup\$ Do you have a correct ollider on the object that also has your script? \$\endgroup\$ – M156 Dec 24 '16 at 12:46
  • \$\begingroup\$ I have a Box Collider 2D on the GameObject \$\endgroup\$ – Paul Dec 24 '16 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\$ – Shuvro Sarkar Dec 25 '16 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 Dec 26 '16 at 17:53
0
\$\begingroup\$

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.

\$\endgroup\$
  • \$\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 Dec 27 '16 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.