@@ -8,30 +8,82 @@ namespace FbxExporters.EditorTools {
8
8
9
9
[ CustomEditor ( typeof ( ExportSettings ) ) ]
10
10
public class ExportSettingsEditor : UnityEditor . Editor {
11
+ Vector2 scrollPos = Vector2 . zero ;
12
+ const float LabelWidth = 225 ;
13
+ const float SelectableLabelMinWidth = 200 ;
14
+ const float BrowseButtonWidth = 55 ;
15
+
11
16
public override void OnInspectorGUI ( ) {
12
17
ExportSettings exportSettings = ( ExportSettings ) target ;
13
18
14
19
// Increasing the label width so that none of the text gets cut off
15
- EditorGUIUtility . labelWidth = 300 ;
20
+ EditorGUIUtility . labelWidth = LabelWidth ;
21
+
22
+ scrollPos = GUILayout . BeginScrollView ( scrollPos ) ;
16
23
17
24
exportSettings . weldVertices = EditorGUILayout . Toggle ( "Weld Vertices:" , exportSettings . weldVertices ) ;
18
25
exportSettings . embedTextures = EditorGUILayout . Toggle ( "Embed Textures:" , exportSettings . embedTextures ) ;
19
26
exportSettings . mayaCompatibleNames = EditorGUILayout . Toggle (
20
- new GUIContent ( "Convert to Maya Compatible Naming:" ,
27
+ new GUIContent ( "Convert to Maya Compatible Naming:" ,
21
28
"In Maya some symbols such as spaces and accents get replaced when importing an FBX " +
22
29
"(e.g. \" foo bar\" becomes \" fooFBXASC032bar\" ). " +
23
30
"On export, convert the names of GameObjects so they are Maya compatible." +
24
- ( exportSettings . mayaCompatibleNames ? "" :
31
+ ( exportSettings . mayaCompatibleNames ? "" :
25
32
"\n \n WARNING: Disabling this feature may result in lost material connections," +
26
- " and unexpected character replacements in Maya." )
33
+ " and unexpected character replacements in Maya." )
27
34
) ,
28
35
exportSettings . mayaCompatibleNames ) ;
29
36
37
+ GUILayout . BeginHorizontal ( ) ;
38
+ GUILayout . Label ( new GUIContent (
39
+ "Model Prefab Path:" ,
40
+ "Relative path for saving Model Prefabs." ) ) ;
41
+
42
+ EditorGUILayout . SelectableLabel ( GetRelativePath ( exportSettings . convertToModelSavePath , Application . dataPath ) ,
43
+ EditorStyles . textField , GUILayout . MinWidth ( SelectableLabelMinWidth ) , GUILayout . Height ( EditorGUIUtility . singleLineHeight ) ) ;
44
+
45
+ if ( GUILayout . Button ( "Browse" , EditorStyles . miniButton , GUILayout . Width ( BrowseButtonWidth ) ) ) {
46
+ string path = EditorUtility . OpenFolderPanel (
47
+ "Select Model Prefabs Path" , Application . dataPath , null
48
+ ) ;
49
+ // Make sure something is selected, and that it is in the Asset folder
50
+ if ( ! string . IsNullOrEmpty ( path ) && path . StartsWith ( Application . dataPath ) ) {
51
+ exportSettings . convertToModelSavePath = path ;
52
+ } else {
53
+ Debug . LogWarning ( "Please select a location in Assets/" ) ;
54
+ }
55
+ }
56
+
57
+ GUILayout . EndHorizontal ( ) ;
58
+ GUILayout . FlexibleSpace ( ) ;
59
+ GUILayout . EndScrollView ( ) ;
60
+
30
61
if ( GUI . changed ) {
31
62
EditorUtility . SetDirty ( exportSettings ) ;
32
63
exportSettings . Save ( ) ;
33
64
}
34
65
}
66
+
67
+ private string GetRelativePath ( string filePath , string folder ) {
68
+ Uri pathUri ;
69
+ try {
70
+ pathUri = new Uri ( filePath ) ;
71
+ }
72
+ catch ( UriFormatException ) {
73
+ return filePath ;
74
+ }
75
+ if ( ! folder . EndsWith ( Path . DirectorySeparatorChar . ToString ( ) ) ) {
76
+ folder += Path . DirectorySeparatorChar ;
77
+ }
78
+ Uri folderUri = new Uri ( folder ) ;
79
+ string relativePath = Uri . UnescapeDataString (
80
+ folderUri . MakeRelativeUri ( pathUri ) . ToString ( ) . Replace ( '/' , Path . DirectorySeparatorChar )
81
+ ) ;
82
+ if ( ! relativePath . StartsWith ( "Assets" ) ) {
83
+ relativePath = string . Format ( "Assets{0}{1}" , Path . DirectorySeparatorChar , relativePath ) ;
84
+ }
85
+ return relativePath ;
86
+ }
35
87
}
36
88
37
89
[ FilePath ( "ProjectSettings/FbxExportSettings.asset" , FilePathAttribute . Location . ProjectFolder ) ]
@@ -40,6 +92,12 @@ public class ExportSettings : FbxExporters.EditorTools.ScriptableSingleton<Expor
40
92
public bool weldVertices = true ;
41
93
public bool embedTextures = false ;
42
94
public bool mayaCompatibleNames = true ;
95
+ public string convertToModelSavePath ;
96
+
97
+ void OnEnable ( )
98
+ {
99
+ convertToModelSavePath = Path . Combine ( Application . dataPath , "Objects" ) ;
100
+ }
43
101
44
102
[ MenuItem ( "Edit/Project Settings/Fbx Export" , priority = 300 ) ]
45
103
static void ShowManager ( )
0 commit comments