protected override ActionResult PerformActionImplementation() { if (MeshSelection.selectedObjectCount < 1) { return(ActionResult.NoSelection); } UndoUtility.RecordMeshAndTransformSelection("Freeze Transforms"); var selection = MeshSelection.topInternal; Vector3[][] positions = new Vector3[selection.Count][]; for (int i = 0, c = selection.Count; i < c; i++) { positions[i] = selection[i].VerticesInWorldSpace(); } for (int i = 0, c = selection.Count; i < c; i++) { ProBuilderMesh pb = selection[i]; bool flipFaces = ShouldFlipFaces(pb.transform.localScale); pb.transform.position = Vector3.zero; pb.transform.rotation = Quaternion.identity; pb.transform.localScale = Vector3.one; foreach (Face face in pb.facesInternal) { face.manualUV = true; if (flipFaces) { face.Reverse(); } } pb.positions = positions[i]; pb.ToMesh(); pb.Refresh(); pb.Optimize(); } ProBuilderEditor.Refresh(); SceneView.RepaintAll(); return(new ActionResult(ActionResult.Status.Success, "Freeze Transforms")); }