public static void DestroyBakedGameObjectsWithEndName(List<GameObject> gameObjectsToDestroy, string endName) { int numLeft = gameObjectsToDestroy.Count; for (int i = 0; i < numLeft; ++i) { GameObject deleteGO = gameObjectsToDestroy[i]; if (string.IsNullOrEmpty(endName) || deleteGO.name.EndsWith(endName)) { gameObjectsToDestroy[i] = null; HEU_PartData.DestroyExistingGeneratedComponentsMeshData(deleteGO, true); HEU_GeneralUtility.DestroyImmediate(deleteGO); } } }