public void Draw(Rect windowRect) { if (!isOpen) { Init(); } isOpen = true; bakeGroup = (BakeGroup)EditorGUILayout.EnumPopup("Bake Mode", bakeGroup); if (bakeGroup == BakeGroup.Selected) { MeshGenSelector(ref selected, "Selected"); } else if (bakeGroup == BakeGroup.AllExcluding) { MeshGenSelector(ref excluded, "Excluded"); } saveMesh = EditorGUILayout.Toggle("Save OBJs", saveMesh); if (saveMesh) { EditorGUILayout.LabelField("Save Path: " + savePath); if (GUILayout.Button("Browse Path")) { savePath = EditorUtility.OpenFolderPanel("Save Directory", Application.dataPath, "folder"); dirInfo = new DirectoryInfo(savePath); } } isStatic = EditorGUILayout.Toggle("Make Static", isStatic); lightmapUV = EditorGUILayout.Toggle("Generate Lightmap UVs", lightmapUV); removeComputer = EditorGUILayout.Toggle("Remove SplineComputers", removeComputer); permanent = EditorGUILayout.Toggle("Permanent", permanent); if (GUILayout.Button("Bake")) { string suff = "all"; if (bakeGroup == BakeGroup.Selected) { suff = "selected"; } if (bakeGroup == BakeGroup.AllExcluding) { suff = "all excluding"; } if (EditorUtility.DisplayDialog("Bake " + suff, "This operation cannot be undone. Are you sure you want to bake the meshes?", "Yes", "No")) { switch (bakeGroup) { case BakeGroup.All: BakeAll(); break; case BakeGroup.Selected: BakeSelected(); break; case BakeGroup.AllExcluding: BakeExcluding(); break; } } } }
public override void Draw(Rect windowRect) { bakeGroup = (BakeGroup)EditorGUILayout.EnumPopup("Bake Mode", bakeGroup); if (bakeGroup == BakeGroup.Selected) { MeshGenSelector(ref selected, "Selected"); } else if (bakeGroup == BakeGroup.AllExcluding) { MeshGenSelector(ref excluded, "Excluded"); } format = (BakeMeshWindow.SaveFormat)EditorGUILayout.EnumPopup("Save Format", format); bool saveMesh = format != BakeMeshWindow.SaveFormat.None; if (format != BakeMeshWindow.SaveFormat.None) { copy = EditorGUILayout.Toggle("Save without baking", copy); } bool isCopy = format != BakeMeshWindow.SaveFormat.None && copy; switch (format) { case BakeMeshWindow.SaveFormat.None: EditorGUILayout.HelpBox("Saves the mesh inside the scene for lightmap", MessageType.Info); break; case BakeMeshWindow.SaveFormat.MeshAsset: EditorGUILayout.HelpBox("Saves the mesh as an .asset file inside the project. This makes using the mesh in prefabs and across scenes possible.", MessageType.Info); break; case BakeMeshWindow.SaveFormat.OBJ: EditorGUILayout.HelpBox("Exports the mesh as an OBJ file which can be imported in a third-party modeling application.", MessageType.Info); break; } EditorGUILayout.Space(); if (!isCopy) { isStatic = EditorGUILayout.Toggle("Make Static", isStatic); permanent = EditorGUILayout.Toggle("Permanent", permanent); if (permanent) { removeComputer = EditorGUILayout.Toggle("Remove SplineComputer", removeComputer); if (removeComputer) { EditorGUILayout.HelpBox("WARNING: Removing Spline Computers may cause other SplineUsers to stop working. Select this if you are sure that no other SplineUser uses the selected Spline Computers.", MessageType.Warning); } } } if (GUILayout.Button("Bake")) { if (saveMesh) { savePath = EditorUtility.OpenFolderPanel("Save Directory", Application.dataPath, "folder"); if (!Directory.Exists(savePath) || savePath == "") { EditorUtility.DisplayDialog("Save error", "Invalid save directory. Please select a valid save directory and try again", "OK"); return; } if (format == BakeMeshWindow.SaveFormat.OBJ && !savePath.StartsWith(Application.dataPath) && !copy) { EditorUtility.DisplayDialog("Save error", "OBJ files can be saved outside of the project folder only when \"Save without baking\" is selected. Please select a directory inside the project in order to save.", "OK"); return; } if (format == BakeMeshWindow.SaveFormat.MeshAsset && !savePath.StartsWith(Application.dataPath)) { EditorUtility.DisplayDialog("Save error", "Asset files cannot be saved outside of the project directory. Please select a path inside the project directory.", "OK"); return; } } string suff = "all"; if (bakeGroup == BakeGroup.Selected) { suff = "selected"; } if (bakeGroup == BakeGroup.AllExcluding) { suff = "all excluding"; } if (EditorUtility.DisplayDialog("Bake " + suff, "This operation cannot be undone. Are you sure you want to bake the meshes?", "Yes", "No")) { switch (bakeGroup) { case BakeGroup.All: BakeAll(); break; case BakeGroup.Selected: BakeSelected(); break; case BakeGroup.AllExcluding: BakeExcluding(); break; } } } }