I would destroy all the components of a gameobject except Transform (of course), the Renderer and MeshFilter …
In practice I instantiate my object, but then I would take away all the scripts that are not those three.
How can I do?
My try:
void CreateMiniMesh () {
ObjectMesh= GameObject.Instantiate(MyOriginalObject);
Component[] AllChidren= ObjectMesh.transform.GetComponentsInChildren<Component>();
foreach (Component childrens in AllChidren) {
if(!childrens.GetComponent<Renderer>()&&
!childrens.GetComponent<Transform>()&&
!childrens.GetComponent<MeshFilter>()){
Destroy(childrens.GetComponent<Behaviour>());
}
}
}