// ------------------------------------------------------------------------------------- protected void OnGUI() { // Increasing the label width so that none of the text gets cut off EditorGUIUtility.labelWidth = LabelWidth; GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); #if UNITY_2018_1_OR_NEWER if (EditorGUILayout.DropdownButton(presetIcon, FocusType.Keyboard, presetIconButton)) { ShowPresetReceiver(); } #endif GUILayout.EndHorizontal(); EditorGUILayout.LabelField("Naming"); EditorGUI.indentLevel++; GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent( "Export Name", "Filename to save model to."), GUILayout.Width(LabelWidth - TextFieldAlignOffset)); EditorGUI.BeginDisabledGroup(DisableNameSelection); // Show the export name with an uneditable ".fbx" at the end //------------------------------------- EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); EditorGUI.indentLevel--; // continually resize to contents var textFieldSize = NameTextFieldStyle.CalcSize(new GUIContent(ExportFileName)); ExportFileName = EditorGUILayout.TextField(ExportFileName, NameTextFieldStyle, GUILayout.Width(textFieldSize.x + 5), GUILayout.MinWidth(5)); ExportFileName = ModelExporter.ConvertToValidFilename(ExportFileName); EditorGUILayout.LabelField("<color=#808080ff>.fbx</color>", FbxExtLabelStyle, GUILayout.Width(FbxExtLabelWidth)); EditorGUI.indentLevel++; EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); //----------------------------------- EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent( "Export Path", "Location where the FBX will be saved."), GUILayout.Width(LabelWidth - FieldOffset)); var pathLabels = ExportSettings.GetMixedSavePaths(FbxSavePaths); if (this is ConvertToPrefabEditorWindow) { pathLabels = ExportSettings.GetRelativeFbxSavePaths(FbxSavePaths, ref m_selectedFbxPath); } SelectedFbxPath = EditorGUILayout.Popup(SelectedFbxPath, pathLabels, GUILayout.MinWidth(SelectableLabelMinWidth)); if (!(this is ConvertToPrefabEditorWindow)) { var exportSettingsEditor = InnerEditor as ExportModelSettingsEditor; // Set export setting for exporting outside the project on choosing a path var exportOutsideProject = !pathLabels[SelectedFbxPath].Substring(0, 6).Equals("Assets"); exportSettingsEditor.SetExportingOutsideProject(exportOutsideProject); } if (GUILayout.Button(new GUIContent("...", "Browse to a new location to export to"), EditorStyles.miniButton, GUILayout.Width(BrowseButtonWidth))) { string initialPath = Application.dataPath; string fullPath = EditorUtility.OpenFolderPanel( "Select Export Model Path", initialPath, null ); // Unless the user canceled, save path. if (!string.IsNullOrEmpty(fullPath)) { var relativePath = ExportSettings.ConvertToAssetRelativePath(fullPath); // If exporting an fbx for a prefab, not allowed to export outside the Assets folder if (this is ConvertToPrefabEditorWindow && string.IsNullOrEmpty(relativePath)) { Debug.LogWarning("Please select a location in the Assets folder"); } // We're exporting outside Assets folder, so store the absolute path else if (string.IsNullOrEmpty(relativePath)) { ExportSettings.AddSavePath(fullPath, FbxSavePaths, exportOutsideProject: true); SelectedFbxPath = 0; } // Store the relative path to the Assets folder else { ExportSettings.AddSavePath(relativePath, FbxSavePaths, exportOutsideProject: false); SelectedFbxPath = 0; } // Make sure focus is removed from the selectable label // otherwise it won't update GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; } } GUILayout.EndHorizontal(); CreateCustomUI(); EditorGUILayout.Space(); EditorGUI.BeginDisabledGroup(DisableTransferAnim); EditorGUI.indentLevel--; GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent( "Transfer Animation", "Transfer transform animation from source to destination. Animation on objects between source and destination will also be transferred to destination." ), GUILayout.Width(LabelWidth - FieldOffset)); GUILayout.EndHorizontal(); EditorGUI.indentLevel++; TransferAnimationSource = EditorGUILayout.ObjectField("Source", TransferAnimationSource, typeof(Transform), allowSceneObjects: true) as Transform; TransferAnimationDest = EditorGUILayout.ObjectField("Destination", TransferAnimationDest, typeof(Transform), allowSceneObjects: true) as Transform; EditorGUILayout.Space(); EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; m_showOptions = EditorGUILayout.Foldout(m_showOptions, "Options"); EditorGUI.indentLevel++; if (m_showOptions) { InnerEditor.OnInspectorGUI(); } // if we are exporting or converting a prefab with overrides, then show a warning if (SelectionContainsPrefabInstanceWithAddedObjects()) { EditorGUILayout.Space(); EditorGUILayout.HelpBox("Prefab instance overrides will be exported", MessageType.Warning, true); } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); DoNotShowDialogUI(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Cancel", GUILayout.Width(ExportButtonWidth))) { this.Close(); } if (GUILayout.Button(ExportButtonName, GUILayout.Width(ExportButtonWidth))) { if (Export()) { this.Close(); } } GUILayout.EndHorizontal(); EditorGUILayout.Space(); // adding a space at bottom of dialog so buttons aren't right at the edge if (GUI.changed) { SaveExportSettings(); } }
// ------------------------------------------------------------------------------------- protected void OnGUI() { // Increasing the label width so that none of the text gets cut off EditorGUIUtility.labelWidth = LabelWidth; GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); #if UNITY_2018_1_OR_NEWER if (EditorGUILayout.DropdownButton(presetIcon, FocusType.Keyboard, presetIconButton)) { ShowPresetReceiver(); } #endif GUILayout.EndHorizontal(); EditorGUILayout.LabelField("Naming"); EditorGUI.indentLevel++; GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent( "Export Name", "Filename to save model to."), GUILayout.Width(LabelWidth - TextFieldAlignOffset)); EditorGUI.BeginDisabledGroup(DisableNameSelection); // Show the export name with an uneditable ".fbx" at the end //------------------------------------- EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight)); EditorGUI.indentLevel--; // continually resize to contents var textFieldSize = NameTextFieldStyle.CalcSize(new GUIContent(ExportFileName)); ExportFileName = EditorGUILayout.TextField(ExportFileName, NameTextFieldStyle, GUILayout.Width(textFieldSize.x + 5), GUILayout.MinWidth(5)); ExportFileName = ModelExporter.ConvertToValidFilename(ExportFileName); EditorGUILayout.LabelField("<color=#808080ff>.fbx</color>", FbxExtLabelStyle, GUILayout.Width(FbxExtLabelWidth)); EditorGUI.indentLevel++; EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); //----------------------------------- EditorGUI.EndDisabledGroup(); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent( "Export Path", "Relative path for saving Model Prefabs."), GUILayout.Width(LabelWidth - FieldOffset)); var pathLabels = ExportSettings.GetRelativeFbxSavePaths(); ExportSettings.instance.SelectedFbxPath = EditorGUILayout.Popup(ExportSettings.instance.SelectedFbxPath, pathLabels, GUILayout.MinWidth(SelectableLabelMinWidth)); if (GUILayout.Button(new GUIContent("...", "Browse to a new location to export to"), EditorStyles.miniButton, GUILayout.Width(BrowseButtonWidth))) { string initialPath = Application.dataPath; string fullPath = EditorUtility.OpenFolderPanel( "Select Export Model Path", initialPath, null ); // Unless the user canceled, make sure they chose something in the Assets folder. if (!string.IsNullOrEmpty(fullPath)) { var relativePath = ExportSettings.ConvertToAssetRelativePath(fullPath); if (string.IsNullOrEmpty(relativePath)) { Debug.LogWarning("Please select a location in the Assets folder"); } else { ExportSettings.AddFbxSavePath(relativePath); // Make sure focus is removed from the selectable label // otherwise it won't update GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; } } } GUILayout.EndHorizontal(); CreateCustomUI(); EditorGUILayout.Space(); EditorGUI.BeginDisabledGroup(DisableTransferAnim); EditorGUI.indentLevel--; GUILayout.BeginHorizontal(); EditorGUILayout.LabelField(new GUIContent( "Transfer Animation", "Transfer transform animation from source to destination. Animation on objects between source and destination will also be transferred to destination." ), GUILayout.Width(LabelWidth - FieldOffset)); GUILayout.EndHorizontal(); EditorGUI.indentLevel++; TransferAnimationSource = EditorGUILayout.ObjectField("Source", TransferAnimationSource, typeof(Transform), allowSceneObjects: true) as Transform; TransferAnimationDest = EditorGUILayout.ObjectField("Destination", TransferAnimationDest, typeof(Transform), allowSceneObjects: true) as Transform; EditorGUILayout.Space(); EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; m_showOptions = EditorGUILayout.Foldout(m_showOptions, "Options"); EditorGUI.indentLevel++; if (m_showOptions) { InnerEditor.OnInspectorGUI(); } GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); DoNotShowDialogUI(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Cancel", GUILayout.Width(ExportButtonWidth))) { this.Close(); } if (GUILayout.Button(ExportButtonName, GUILayout.Width(ExportButtonWidth))) { if (Export()) { this.Close(); } } GUILayout.EndHorizontal(); if (GUI.changed) { SaveExportSettings(); } }