1
- using System . Collections ;
1
+ using System . Collections ;
2
2
using System . Collections . Generic ;
3
3
using UnityEngine ;
4
4
using UnityEditor ;
@@ -82,24 +82,39 @@ protected override void OnEnable ()
82
82
m_prefabExtLabelWidth = m_fbxExtLabelStyle . CalcSize ( new GUIContent ( ".prefab" ) ) . x ;
83
83
}
84
84
85
- protected override void Export ( )
85
+ protected override bool Export ( )
86
86
{
87
+ if ( string . IsNullOrEmpty ( m_exportFileName ) ) {
88
+ Debug . LogError ( "FbxExporter: Please specify an fbx filename" ) ;
89
+ return false ;
90
+ }
91
+
92
+ if ( string . IsNullOrEmpty ( m_prefabFileName ) ) {
93
+ Debug . LogError ( "FbxExporter: Please specify a prefab filename" ) ;
94
+ return false ;
95
+ }
96
+
87
97
var fbxDirPath = ExportSettings . GetFbxAbsoluteSavePath ( ) ;
88
98
var fbxPath = System . IO . Path . Combine ( fbxDirPath , m_exportFileName + ".fbx" ) ;
89
99
90
100
var prefabDirPath = ExportSettings . GetPrefabAbsoluteSavePath ( ) ;
91
101
var prefabPath = System . IO . Path . Combine ( prefabDirPath , m_prefabFileName + ".prefab" ) ;
92
102
103
+ // check if file already exists, give a warning if it does
104
+ if ( ! OverwriteExistingFile ( fbxPath ) || ! OverwriteExistingFile ( prefabPath ) ) {
105
+ return false ;
106
+ }
107
+
93
108
if ( ToExport == null ) {
94
109
Debug . LogError ( "FbxExporter: missing object for conversion" ) ;
95
- return ;
110
+ return false ;
96
111
}
97
112
98
113
if ( ToExport . Length == 1 ) {
99
114
var go = ModelExporter . GetGameObject ( ToExport [ 0 ] ) ;
100
115
101
116
if ( ! OverwriteExistingFile ( prefabPath ) ) {
102
- return ;
117
+ return false ;
103
118
}
104
119
105
120
// Only create the prefab (no FBX export) if we have selected the root of a model prefab instance.
@@ -113,19 +128,19 @@ protected override void Export ()
113
128
114
129
if ( string . Equals ( System . IO . Path . GetFullPath ( fbxPath ) , System . IO . Path . GetFullPath ( mainAssetAbsPath ) ) ) {
115
130
ConvertToModel . SetupFbxPrefab ( go , mainAsset , relPrefabPath , mainAssetAbsPath ) ;
116
- return ;
131
+ return true ;
117
132
}
118
133
}
119
134
120
135
// check if file already exists, give a warning if it does
121
136
if ( ! OverwriteExistingFile ( fbxPath ) ) {
122
- return ;
137
+ return false ;
123
138
}
124
139
125
140
ConvertToModel . Convert (
126
141
go , fbxFullPath : fbxPath , prefabFullPath : prefabPath , exportOptions : ExportSettings . instance . convertToPrefabSettings . info
127
142
) ;
128
- return ;
143
+ return true ;
129
144
}
130
145
131
146
foreach ( var obj in ToExport ) {
@@ -134,6 +149,7 @@ protected override void Export ()
134
149
go , fbxDirectoryFullPath : fbxDirPath , prefabDirectoryFullPath : prefabDirPath , exportOptions : ExportSettings . instance . convertToPrefabSettings . info
135
150
) ;
136
151
}
152
+ return true ;
137
153
}
138
154
139
155
protected override ExportOptionsSettingsSerializeBase SettingsObject
0 commit comments