Storing the status of a GameObject.

Hello there,

Im new to Unity, and i got a small problem.

Imagine i have a square, on which another gameobject should become visible after i click on that gameobject. It should however only happen once, and on the second click it should do nothing.

I can create the object on a click, but how can i store the fact that the gameobject has been clicked already, so it wont create a new gameobject on every click. What i would like is for example a variable named "inUse" attached to every GameObject, which can have the value true or false. Ofcourse, when a new gameobject gets created it should be set to false.

I think, i need to add a new component or something to the gameobject that keeps track of this, but i cant seem to do that ;)

I hope someone can help.

Thanks in advance.

Why don't you just add the variable to the script that does the instantiating?

as Spree said, add the value to the script that does the instantiating. This script will get added to each of the gameobjects. At the top add:

var clicked = false;

and after the if function that checks if it's clicked add

clicked = true;.

the if function I mentioned should look something like this:

if(mouseclick) {//do stuff)

make it (mouseclick && !clicked) {//dostuff}