/// <summary> /// Called from ProGrids. /// </summary> /// <param name="snapVal"></param> void PushToGrid(float snapVal) { UndoUtility.RecordSelection(selection.ToArray(), "Push elements to Grid"); if (selectMode == SelectMode.Object || selectMode == SelectMode.None) { return; } for (int i = 0, c = MeshSelection.selectedObjectCount; i < c; i++) { ProBuilderMesh mesh = selection[i]; if (mesh.selectedVertexCount < 1) { continue; } var indexes = mesh.GetCoincidentVertices(mesh.selectedIndexesInternal); Snapping.SnapVertices(mesh, indexes, Vector3.one * snapVal); mesh.ToMesh(); mesh.Refresh(); mesh.Optimize(); } UpdateSelection(); }