i cant destroy a certain object because i cant re-create it.
so i need to disable the renderer and all the scripts in it plus children of it .
whats the best method for doing this?
i cant destroy a certain object because i cant re-create it.
so i need to disable the renderer and all the scripts in it plus children of it .
whats the best method for doing this?
What you describe can be done using SetActiveRecursively
Saying you can’t destroy it because you can’t recreate it might mean you want to save it as a prefab rather than setting it to be not active?
If so look at PrefabUtility.CreatePrefab
Hope those links help,
Scribe
public Transform object; //the object you want to disappear
private Transform children; //the children of the above object
void Update () {
if( ... ) /*if you would like it to disappear*/ {
children = object.gameObject.GetComponentsInChildren<Renderer>() as Transform[];
foreach(Renderer r in children as Transform){
r.renderer.enabled = false;
}
}
}