Skip to content

Commit 97afeff

Browse files
committed
add uneditable ".prefab" after prefab name
1 parent f9408b9 commit 97afeff

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Editor
1212
{
1313
public static class ConvertToModel
1414
{
15-
const string MenuItemName1 = "GameObject/Convert To Linked Prefab Instance";
15+
const string MenuItemName1 = "GameObject/Convert To Linked Prefab Instance...";
1616

1717
/// <summary>
1818
/// OnContextItem is called either:

Assets/FbxExporters/Editor/ConvertToPrefabEditorWindow.cs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public class ConvertToPrefabEditorWindow : ExportOptionsEditorWindow
1818
private GameObject[] m_toConvert;
1919
private string m_prefabFileName = "";
2020

21+
private float m_prefabExtLabelWidth;
22+
2123
public static void Init (IEnumerable<GameObject> toConvert)
2224
{
2325
ConvertToPrefabEditorWindow window = CreateWindow<ConvertToPrefabEditorWindow> ();
@@ -43,6 +45,7 @@ protected override void OnEnable ()
4345
if (!m_innerEditor) {
4446
m_innerEditor = UnityEditor.Editor.CreateEditor (ExportSettings.instance.convertToPrefabSettings);
4547
}
48+
m_prefabExtLabelWidth = m_fbxExtLabelStyle.CalcSize (new GUIContent (".prefab")).x;
4649
}
4750

4851
protected override void Export ()
@@ -92,16 +95,25 @@ protected override void CreateCustomUI ()
9295
GUILayout.BeginHorizontal ();
9396
EditorGUILayout.LabelField(new GUIContent(
9497
"Prefab Name:",
95-
"Filename to save prefab to."),GUILayout.Width(LabelWidth-FieldOffset));
98+
"Filename to save prefab to."),GUILayout.Width(LabelWidth-TextFieldAlignOffset));
9699

97100
EditorGUI.BeginDisabledGroup (DisableNameSelection());
98-
var textFieldStyle = new GUIStyle (EditorStyles.textField);
99-
// increase padding to match filename text field
100-
var padding = textFieldStyle.padding;
101-
padding.left = padding.left + 3;
102-
textFieldStyle.padding = padding;
103-
m_prefabFileName = EditorGUILayout.TextField (m_prefabFileName, textFieldStyle);
104-
m_prefabFileName = ModelExporter.ConvertToValidFilename (m_prefabFileName);
101+
// Show the export name with an uneditable ".prefab" at the end
102+
//-------------------------------------
103+
EditorGUILayout.BeginVertical ();
104+
EditorGUILayout.BeginHorizontal(EditorStyles.textField, GUILayout.Height(EditorGUIUtility.singleLineHeight));
105+
EditorGUI.indentLevel--;
106+
// continually resize to contents
107+
var textFieldSize = m_nameTextFieldStyle.CalcSize (new GUIContent(m_prefabFileName));
108+
m_exportFileName = EditorGUILayout.TextField (m_prefabFileName, m_nameTextFieldStyle, GUILayout.Width(textFieldSize.x + 5), GUILayout.MinWidth(5));
109+
m_exportFileName = ModelExporter.ConvertToValidFilename (m_prefabFileName);
110+
111+
EditorGUILayout.LabelField ("<color=#808080ff>.prefab</color>", m_fbxExtLabelStyle, GUILayout.Width(m_prefabExtLabelWidth));
112+
EditorGUI.indentLevel++;
113+
114+
EditorGUILayout.EndHorizontal();
115+
EditorGUILayout.EndVertical ();
116+
//-----------------------------------
105117
EditorGUI.EndDisabledGroup ();
106118
GUILayout.EndHorizontal ();
107119

0 commit comments

Comments
 (0)