Advance when all items clicked

Hi all:

Right now I have an array with 4 gameobjects in it. When the user comes up to a stop they need to click on those 4 objects to pop a question and advance. The problem is, with the way I have it currently built, the user can just click on a single item 4 times and the question will pop.

So my question to you all is, what is the best way to force the user to have to click on each item I want them to? Dictionary, Array, ArrayList? Something I have never heard of? I’m staying away from hard-coding it by saying things like “if has been clicked then” as each stop has a different number of items.

	for(i = 0; i < gos.Length; i++)
	{
		if(hit.collider.gameObject == gos*)*
  •   	{*
    
  •   		bool foundit = false;*
    
  •   		if(clickedObjects[0] == null)*
    
  •   		{*
    

_ clickedObjects = hit.collider.gameObject;_
* count++;*
* }*
* for(int j = 0; j < gos.Length; j++)*
* {*

_ if(gos*)
{
Debug.Log("gos instance id is " + gos.GetInstanceID());
}
if(gos == clickedObjects[j])
{
foundit = true;
print("Trying this again. Found it is now set to " + foundit);
break;
}
}*_

* if(!foundit)*
* {*
_ clickedObjects = hit.collider.gameObject;
if(clickedObjects*)
{
Debug.Log("clickedObject instance id is " + clickedObjects.GetInstanceID());
}
StartCoroutine(DisableInput(gos));
count++;
print("The count is now at: " + count);
}*_

* }*
* }*
Thank you.

To prevent restructuring, you could add an array to keep references to the already-clicked objects. Then you would do something like this. This isn’t a copy/paste solution, as some bits are missing. But it should give you one idea for how it could work.

if(hit.collider.gameObject == gos*)*

{
bool foundit = false;
for(j = 0; j < 4; j++)
{
if(gos == clickedObjects[j])
{
foundit = true;
break;
}
}
if(!foundit)
{
// statement to add hit.collider.gameObject to clickedObjects here
StartCoroutine(DisableInput(gos));
count++;
print("The count is now at: " + count);
}
}