public override void OnInspectorGUI() { if (GUILayout.Button("Export as XML")) { BuildrXMLExporter.Export("Assets/BuildR/Exported/", "buildrdataexport", (BuildrData)target); AssetDatabase.Refresh(); } DrawDefaultInspector(); }
public static void InspectorGUI(BuildrEditMode editMode, BuildrData data) { if (data.plan == null || data.plan.numberOfVolumes == 0) { EditorGUILayout.HelpBox("There are no defined volumes, go to Floorplan and define one", MessageType.Error); return; } const int guiWidth = 400; const int textWidth = 348; const int toggleWidth = 25; const int helpWidth = 20; CURRENT_TRANSFORM = editMode.transform; EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Filename", GUILayout.Width(225)); data.exportFilename = EditorGUILayout.TextField(data.exportFilename, GUILayout.Width(175)); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Filetype", GUILayout.Width(350)); data.filetype = (BuildrData.filetypes)EditorGUILayout.EnumPopup(data.filetype, GUILayout.Width(50)); switch (data.filetype) { case BuildrData.filetypes.obj: FILE_EXTENTION = ".obj"; break; case BuildrData.filetypes.fbx: FILE_EXTENTION = ".fbx"; break; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Export Full Mesh", GUILayout.Width(textWidth)); data.fullmesh = EditorGUILayout.Toggle(data.fullmesh, GUILayout.Width(toggleWidth)); if (GUILayout.Button("?", GUILayout.Width(helpWidth))) { string helpTitle = "Help - Export Full Mesh"; string helpBody = "Select this checkbox if you want your export the full detail model."; EditorUtility.DisplayDialog(helpTitle, helpBody, "close"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Place Exported Model Into Scene", GUILayout.Width(textWidth)); data.placeIntoScene = EditorGUILayout.Toggle(data.placeIntoScene, GUILayout.Width(toggleWidth)); if (GUILayout.Button("?", GUILayout.Width(helpWidth))) { string helpTitle = "Help - Place Exported Model Into Scene"; string helpBody = "Select this checkbox if you want your exported models to be copied into your scene." + "\nThese will be positioned correctly and will include colliders and LOD models if you opt to export them also."; EditorUtility.DisplayDialog(helpTitle, helpBody, "close"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Copy Textures into Export Folder", GUILayout.Width(textWidth)); data.copyTexturesIntoExportFolder = EditorGUILayout.Toggle(data.copyTexturesIntoExportFolder, GUILayout.Width(toggleWidth)); if (GUILayout.Button("?", GUILayout.Width(helpWidth))) { string helpTitle = "Help - Copy Textures into Export Folder"; string helpBody = "Check this box if you want to copy the textures you are using into the export folder." + "\nThis is useful if you plan to use the exported model elsewhere. Having the model and the textures in one folder will allow you to move this model with ease."; EditorUtility.DisplayDialog(helpTitle, helpBody, "close"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Export Collider"); data.generateCollider = (BuildrData.ColliderGenerationModes)EditorGUILayout.EnumPopup(data.generateCollider, GUILayout.Width(80)); if (GUILayout.Button("?", GUILayout.Width(helpWidth))) { string helpTitle = "Help - Export Collider Mesh"; string helpBody = "Check this box if you wish to generate a collider mesh for your model." + "\nThis will generate a mesh to be used with colliders."; EditorUtility.DisplayDialog(helpTitle, helpBody, "close"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Export as Prefab", GUILayout.Width(textWidth)); data.createPrefabOnExport = EditorGUILayout.Toggle(data.createPrefabOnExport, GUILayout.Width(toggleWidth)); if (GUILayout.Button("?", GUILayout.Width(helpWidth))) { string helpTitle = "Help - Export as Prefab"; string helpBody = "Select this if you wish to create a prefab of your model." + "\nThis is recommended if you're exporting a collider so they will get packaged together."; EditorUtility.DisplayDialog(helpTitle, helpBody, "close"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Export a Low Detail Version", GUILayout.Width(textWidth)); data.exportLowLOD = EditorGUILayout.Toggle(data.exportLowLOD, GUILayout.Width(toggleWidth)); if (GUILayout.Button("?", GUILayout.Width(helpWidth))) { string helpTitle = "Help - Export a Low Detail Version"; string helpBody = "Check this box to export a simplified model of your building." + "\nIdeal to use as a low level of detail version of your model." + "\nGeometry will be significantly reduced." + "\nFacades will flat and exported as a single atlased texture" + "\nThe model will use 1 draw call and will have around 10% of the triangles and verticies"; EditorUtility.DisplayDialog(helpTitle, helpBody, "close"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Export with tangents", GUILayout.Width(textWidth)); data.includeTangents = EditorGUILayout.Toggle(data.includeTangents, GUILayout.Width(toggleWidth)); if (GUILayout.Button("?", GUILayout.Width(helpWidth))) { string helpTitle = "Help - with tangents"; string helpBody = "Export the models with calculated tangents." + "\nSome shaders require tangents to be calculated on the model." + "\nUnity will do this automatically on all imported meshes so it's not neccessary here." + "/nBut you might want them if you're taking them to another program."; EditorUtility.DisplayDialog(helpTitle, helpBody, "close"); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); bool unreadableTextures = false; bool nullTextures = false; string unreadableTextureList = ""; foreach (BuildrTexture bTexture in data.textures)//check texture readablility { if (bTexture.type == BuildrTexture.Types.Substance) { continue;//substances are preset in BuildrTexture class } if (bTexture.texture != null) { string texturePath = AssetDatabase.GetAssetPath(bTexture.texture); TextureImporter textureImporter = (TextureImporter)AssetImporter.GetAtPath(texturePath); if (!textureImporter.isReadable) { unreadableTextures = true; if (unreadableTextureList.Length > 0) { unreadableTextureList += ", "; } unreadableTextureList += "'" + bTexture.name + "'"; } } else { nullTextures = true; } } if (unreadableTextures) { EditorGUILayout.HelpBox("Unreadable Texture Error." + "\nThe following textures you are useing are not readable." + "\n" + unreadableTextureList + "." + "\nPlease select the readable checkbox under advanced texture settings." + "\nOr move this texture to the BuildR texture folder and reimport.", MessageType.Error); } if (nullTextures) { EditorGUILayout.HelpBox("Null Texture Error" + "\nSome of the textures have not been set" + "\nEnsure you are not using null textures to proceed.", MessageType.Error); } bool usingSubstances = false; foreach (BuildrTexture bTexture in data.textures) { if (bTexture.type == BuildrTexture.Types.Substance) { usingSubstances = true; break; } } if (usingSubstances) { EditorGUILayout.HelpBox("Model uses Substance textures." + "\nExporting model to " + data.filetype + " will lose references to this texture and it will be rendered white.", MessageType.Warning); } EditorGUI.BeginDisabledGroup(unreadableTextures || nullTextures); if (GUILayout.Button("Export", GUILayout.Width(guiWidth), GUILayout.Height(40))) { ExportModel(data); } if (GUILayout.Button("Export Data to XML", GUILayout.Width(guiWidth))) { BuildrXMLExporter.Export(ROOT_FOLDER + data.exportFilename + "/", data.exportFilename, data); AssetDatabase.Refresh(); } EditorGUI.EndDisabledGroup(); CURRENT_TRANSFORM = null; }