Selecting One Piece, Moving to Selected Area

i have an array of gameobjects set up with a 'piece.js' script attached. here's what i'm having trouble with... i want to click one piece (with an OnMouseUp event) and have it sort of 'activate' to be moved. the problem is it activates everything. setting booleans inside that script didn't help, because it would just set true or false to everything the script is attached to.

i started to store the clicked object into an array like below ::

  arr.Add(gameObject);

  for (var go : GameObject in arr){
    isSelected = true;
  } 

this worked to an extent, but it then just adds objects to the array as i click them. is it possible to limit this array to 1 object? seems like something super basic but i'm at a loss.

Rather than "limiting the array to 1 object", just use a gameObject variable. i.e.

static var clickedObj : GameObject;

Alternatively - when you say "is it possible to limit this array to 1 object?", do you mean "is it possible to limit the array to 1 entry per object?" To do this, you'd iterate through the array, comparing whether or not the object already exists in the array before adding it.


Update as per comments:

You can store to the `clickedObj` variable simply by assigning with '`=`'. i.e.

clickedObj = gameObject;