3using System.Collections;
13 [MenuItem(
"Assets/Export Model/STL (Ascii)",
true)]
14 [MenuItem(
"Assets/Export Model/STL (Binary)",
true)]
15 static bool VerifyExport()
17 return Selection.transforms.SelectMany(x => x.GetComponentsInChildren<MeshFilter>()).FirstOrDefault(y => y.sharedMesh !=
null) !=
null;
20 [MenuItem(
"Assets/Export Model/STL (Ascii)",
false, 30)]
21 static void MenuExportAscii()
23 ExportWithFileDialog(Selection.gameObjects,
FileType.Ascii);
26 [MenuItem(
"Assets/Export Model/STL (Binary)",
false, 30)]
27 static void MenuExportBinary()
29 ExportWithFileDialog(Selection.gameObjects,
FileType.Binary);
32 private static void ExportWithFileDialog(GameObject[] gameObjects,
FileType type)
34 if(gameObjects ==
null || gameObjects.Length < 1)
36 Debug.LogWarning(
"Attempting to export STL file with no GameObject selected. For reasons that should be obvious this is not allowed.");
40 string path = EditorUtility.SaveFilePanel(
"Save Mesh to STL",
"", gameObjects.FirstOrDefault().name,
"stl");
42 if( pb_Stl_Exporter.Export(path, gameObjects, type) )
44 string full = path.Replace(
"\\",
"/");
47 if(full.Contains(Application.dataPath))
49 string relative = full.Replace(Application.dataPath,
"Assets");
54 Object o = AssetDatabase.LoadAssetAtPath<
Object>(relative);
58 EditorGUIUtility.PingObject(o);
60 AssetDatabase.Refresh();