//Handles changing the current tank public void ChangeTankModel(GameObject newModel) { if (transform.childCount > 0) { Transform tankChild = transform.GetChild(0); if (tankChild != null) { Destroy(tankChild.gameObject); } } GameObject newTankMesh = (GameObject)Instantiate(newModel, transform.position, transform.rotation); newTankMesh.transform.localScale = transform.localScale; newTankMesh.transform.SetParent(transform, true); m_CurrentTankDisplay = newTankMesh.GetComponent <TankDisplay>(); m_CurrentTankDisplay.HideShadow(); PlayerDataManager dataManager = PlayerDataManager.s_Instance; if (dataManager != null) { int decorationIndex = dataManager.selectedDecoration; LoadDecorationForIndex(decorationIndex, dataManager.GetSelectedMaterialForDecoration(decorationIndex)); } }
//Handles changing the current tank public void ChangeTankModel(GameObject newModel) { if (transform.childCount > 0) { Transform tankChild = transform.GetChild(0); if (tankChild != null) { Destroy(tankChild.gameObject); } } GameObject newTankMesh = (GameObject)Instantiate(newModel, transform.position, transform.rotation); newTankMesh.transform.localScale = transform.localScale; newTankMesh.transform.SetParent(transform, true); m_CurrentTankDisplay = newTankMesh.GetComponent <TankDisplay>(); m_CurrentTankDisplay.HideShadow(); }