public static MeshSelection ExpandSelection(MeshSelection selection) { selection = selection.ToFaces(false); foreach (PBMesh pbMesh in selection.GetSelectedMeshes().ToArray()) { ProBuilderMesh mesh = pbMesh.ProBuilderMesh; IList <Face> selectedFaces = new List <Face>(); mesh.GetFaces(selection.GetFaces(pbMesh).ToArray(), selectedFaces); HashSet <int> groupsHs = new HashSet <int>(); for (int i = 0; i < selectedFaces.Count; ++i) { Face face = selectedFaces[i]; if (!groupsHs.Contains(face.smoothingGroup)) { groupsHs.Add(face.smoothingGroup); } } IList <int> selectedIndices = new List <int>(); IList <Face> faces = mesh.faces; for (int i = 0; i < faces.Count; ++i) { Face face = faces[i]; if (groupsHs.Contains(face.smoothingGroup)) { selectedIndices.Add(i); } } selection.SelectedFaces[pbMesh.gameObject] = selectedIndices; } return(selection); }