more prefab issues..

so another issue with prefabs…

//pass in array of prefab names
public function SetData(parts : Array ){
//set variable for setting vales to
var reset = Vector3(5,5,5);
//loop over all parts
for (i=0; i<parts.length; i++){
//load part
var TILE : GameObject = Resources.Load(parts*);*
//instanciate
Instantiate(TILE);
//loop over all children
for (var child : Transform in TILE.transform) {
//set positions
child.position = (reset);
child.eulerAngles = (reset);
*}//end for child *
}//end for parts
}//end setData
right all works well and good
in another script attched to the prefab i destroy them when conditions are met…
var OtherScript : mainbody;
OtherScript = FindObjectOfType(mainbody);
function Update() {

  • if(OtherScript.gameOver <= 0 ){*
  • Destroy (gameObject);*
    }
    }
    i push play …
    all works well, prefab are created and values set
    hit stop.
    all the values of the children in the prefabs in my project window have all changed from their default (0,0,0) to the value i set in code. this is odd. why would it change the prefaba and thier clones? why do the prefabs not revert after the game has stopped.
    next time i Instantiate the objects get the values from last time. am i setting the prefabs and not the clones?
    do i have a fundamental programming /logic flow with unity?
    i want to clone prefabs from a list
    then set the childrens position in space.
    then use the parent to move the children from the parents center.
    can any one help

When you call Instantiate, it returns the new in scene gameobject it has cloned from your asset, which you should store and make alterations to. Right now you are making alterations to the asset you have loaded, not the one you have created, hence they get stored in the prefab.

//pass in array of prefab names 
public function SetData(parts : Array ){ 
  //set variable for setting vales to 
  var reset = Vector3(5,5,5); 
  //loop over all parts 
  for (i=0; i<parts.length; i++){ 
    //load part 
    var tilePrefab : GameObject = Resources.Load(parts[i]); 
    //instantiate 
    var tileObject : GameObject = Instantiate(tilePrefab); 
    //loop over all children 
    for (var child : Transform in tileObject .transform) { 
      //set positions 
      child.position = (reset); 
      child.eulerAngles = (reset); 
    }//end for child	
  }//end for parts 
}//end setData

This should only affect the instantiated objects now, not the prefabs.