public void DeleteModelFromTerrain(GameObject gameObject) { var toDelete = ModelsOnTerrain.First(x => x.GameObject == gameObject); GameObject.Destroy(toDelete.GameObject); ModelsOnTerrain.Remove(toDelete); }
public void DeleteModel(Guid modelGuid) { var objToDelete = ModelsOnTerrain.Where(x => x.ModelGuid == modelGuid).ToList(); foreach (var obj in objToDelete) { GameObject.Destroy(obj.GameObject); ModelsOnTerrain.Remove(obj); } GameObject.Destroy(Models[modelGuid].GameObject); Models.Remove(modelGuid); }