I have some code that is instantiating some pickup objects and that all works fine, but when I stop play testing, ONLY the pickup items are being left behind. The pickup items are a prefab containing a capsule mesh, a script, and a point light. I am also getting a Debug error.
Script:
var pickupObjects : GameObject[];
var dropChances : float[];
function OnDestroy(){
var count = 0;
for(var pickup : GameObject in pickupObjects){
var random = Random.Range(0,100);
if(random>dropChances[count]){
var targetPos = transform.position;
targetPos.y += transform.localScale.y/2;
Instantiate(pickup,targetPos,transform.rotation);
}
count++;
}
}
Error:
Some objects were not cleaned up when closing the scene