change or replace objects

hello how can it be possible when the player clicks an object 1 , object 2 replaces to object 3

.. and is it possible when player clicks object 1 object 2 will be removed?

just store the references of objects in each other and Destroy objects that you don't want and Instantiate others. something like this

var object2 : GameObject;
var object3 : GameObject;
function OnMouseDown ()
{
//if you want to replace you should Instantiate in object2's position
Instantiate(object3,object2.transform.position,object2.transform.rotation);
//remove object 2
Destroy(object2);
}

i came across this same problem as well but the problem with this solution is that at a short instant of time both objects share the same space making there colliers collide launching the newly instantiated object into oblivion. the only way i could find to get around this is by making the script instantiate an empty game object that deletes object2 and then instantiate object 3 then deleting itself.