@@ -130,8 +130,7 @@ protected Transform TransferAnimationSource {
130
130
return SettingsObject . AnimationSource ;
131
131
}
132
132
set {
133
- var selectedGO = ModelExporter . GetGameObject ( ToExport [ 0 ] ) ;
134
- if ( ! TransferAnimationSourceIsValid ( value , selectedGO ) ) {
133
+ if ( ! TransferAnimationSourceIsValid ( value ) ) {
135
134
return ;
136
135
}
137
136
SettingsObject . SetAnimationSource ( value ) ;
@@ -143,8 +142,7 @@ protected Transform TransferAnimationDest {
143
142
return SettingsObject . AnimationDest ;
144
143
}
145
144
set {
146
- var selectedGO = ModelExporter . GetGameObject ( ToExport [ 0 ] ) ;
147
- if ( ! TransferAnimationDestIsValid ( value , selectedGO ) ) {
145
+ if ( ! TransferAnimationDestIsValid ( value ) ) {
148
146
return ;
149
147
}
150
148
SettingsObject . SetAnimationDest ( value ) ;
@@ -181,11 +179,18 @@ protected bool IsInSameHierarchy(Transform t1, Transform t2){
181
179
}
182
180
183
181
184
- protected bool TransferAnimationSourceIsValid ( Transform newValue , GameObject selectedGO ) {
182
+ protected bool TransferAnimationSourceIsValid ( Transform newValue ) {
185
183
if ( ! newValue ) {
186
184
return true ;
187
185
}
188
186
187
+ if ( ToExport == null || ToExport . Length <= 0 ) {
188
+ Debug . LogWarning ( "FbxExportSettings: no Objects selected for export, can't transfer animation" ) ;
189
+ return false ;
190
+ }
191
+
192
+ var selectedGO = ModelExporter . GetGameObject ( ToExport [ 0 ] ) ;
193
+
189
194
// source must be ancestor to dest
190
195
if ( TransferAnimationDest && ! IsAncestor ( newValue , TransferAnimationDest ) ) {
191
196
Debug . LogWarningFormat ( "FbxExportSettings: Source {0} must be an ancestor of {1}" , newValue . name , TransferAnimationDest . name ) ;
@@ -199,11 +204,18 @@ protected bool TransferAnimationSourceIsValid(Transform newValue, GameObject sel
199
204
return true ;
200
205
}
201
206
202
- protected bool TransferAnimationDestIsValid ( Transform newValue , GameObject selectedGO ) {
207
+ protected bool TransferAnimationDestIsValid ( Transform newValue ) {
203
208
if ( ! newValue ) {
204
209
return true ;
205
210
}
206
211
212
+ if ( ToExport == null || ToExport . Length <= 0 ) {
213
+ Debug . LogWarning ( "FbxExportSettings: no Objects selected for export, can't transfer animation" ) ;
214
+ return false ;
215
+ }
216
+
217
+ var selectedGO = ModelExporter . GetGameObject ( ToExport [ 0 ] ) ;
218
+
207
219
// source must be ancestor to dest
208
220
if ( TransferAnimationSource && ! IsAncestor ( TransferAnimationSource , newValue ) ) {
209
221
Debug . LogWarningFormat ( "FbxExportSettings: Destination {0} must be a descendant of {1}" , newValue . name , TransferAnimationSource . name ) ;
0 commit comments