Here is the code that crashes unity, I’m not sure what is wrong.
void Update () {
if(pb1){
ShowB1Ghost();
}
}
void ShowB1Ghost(){
b1Ghost.SetActive(true);
RaycastHit hit;
if (Physics.Raycast (cam.ScreenPointToRay (Input.mousePosition), out hit, Mathf.Infinity, Mask)) {
b1Ghost.transform.position = hit.point;
if(Input.GetMouseButton(0)){
pb1 = false;
b1Ghost.SetActive(false);
Transform building = PoolManager.Pools["Bases"].Spawn(SpawnB1.transform, b1Ghost.transform.position, b1Ghost.transform.rotation);
MeshRenderer[] renderers = (MeshRenderer[]) building.GetComponentsInChildren<MeshRenderer>();
GameObject[] objsToAdd = new GameObject[renderers.Length];
for (int r = 0; r < renderers.Length; r++){
objsToAdd[r] = renderers[r].gameObject;
}
skinnedMeshBakerGood.AddDeleteGameObjects(objsToAdd,null);
skinnedMeshBakerGood.Apply();
}
}
}