Eliminate prefab and replace with a bunch of different ones

Hi everyone, I’ve been trying to make a thing happen, where you touch a given prefab and it spawns a series of different ones (think like clicking on a box, having it vanish and spawning a bunch of coins or something along those lines) but I can’t for the life of me figure out exactly how to do it, at runtime, in a reasonably performant manner.

Maybe I’m just too new to Unity, or maybe it’s the fact that it’s 2 in the morning here, but… could anyone point me in the right direction?

Thanks!!

Attach this script to an object. Select the object in the Hierarchy and drag the prefab to “goPrefab”. For this example code, the prefab must have a Rigidbody:

public var goPrefab : GameObject;

function OnMouseDown() {
	for (var i = 0; i < 100; i++) {
		var go : GameObject = Instantiate(goPrefab);
		go.transform.rotation = Random.rotation;
		go.rigidbody.AddForce(go.transform.forward * 300);
	}
	Destroy(gameObject);
}