/** * \brief Instantiates the passed GameObject exactly as GameObject.Instantiate() would. * If the passed object is detected to be a pb_Object, it will forcibly reconstruct the Mesh * property. */ public static GameObject Instantiate(GameObject prefab, Vector3 position, Quaternion rotation) { GameObject go = (GameObject)GameObject.Instantiate(prefab, position, rotation); pb_Object pb = go.GetComponent <pb_Object>(); if (pb != null) { pb.ReconstructMesh(); } foreach (Transform t in go.transform) { pb = t.GetComponent <pb_Object>(); if (pb == null) { continue; } pb.ReconstructMesh(); } return(go); }