Skip to content

Commit a2a05db

Browse files
committed
check export set length before accessing
just in case
1 parent 7c049cc commit a2a05db

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

Assets/FbxExporters/Editor/ExportModelEditorWindow.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ protected Transform TransferAnimationSource {
130130
return SettingsObject.AnimationSource;
131131
}
132132
set {
133-
var selectedGO = ModelExporter.GetGameObject(ToExport[0]);
134-
if (!TransferAnimationSourceIsValid (value, selectedGO)) {
133+
if (!TransferAnimationSourceIsValid (value)) {
135134
return;
136135
}
137136
SettingsObject.SetAnimationSource (value);
@@ -143,8 +142,7 @@ protected Transform TransferAnimationDest {
143142
return SettingsObject.AnimationDest;
144143
}
145144
set {
146-
var selectedGO = ModelExporter.GetGameObject(ToExport[0]);
147-
if (!TransferAnimationDestIsValid (value, selectedGO)) {
145+
if (!TransferAnimationDestIsValid (value)) {
148146
return;
149147
}
150148
SettingsObject.SetAnimationDest (value);
@@ -181,11 +179,18 @@ protected bool IsInSameHierarchy(Transform t1, Transform t2){
181179
}
182180

183181

184-
protected bool TransferAnimationSourceIsValid(Transform newValue, GameObject selectedGO){
182+
protected bool TransferAnimationSourceIsValid(Transform newValue){
185183
if (!newValue) {
186184
return true;
187185
}
188186

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+
189194
// source must be ancestor to dest
190195
if (TransferAnimationDest && !IsAncestor(newValue, TransferAnimationDest)) {
191196
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
199204
return true;
200205
}
201206

202-
protected bool TransferAnimationDestIsValid(Transform newValue, GameObject selectedGO){
207+
protected bool TransferAnimationDestIsValid(Transform newValue){
203208
if (!newValue) {
204209
return true;
205210
}
206211

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+
207219
// source must be ancestor to dest
208220
if (TransferAnimationSource && !IsAncestor(TransferAnimationSource, newValue)) {
209221
Debug.LogWarningFormat("FbxExportSettings: Destination {0} must be a descendant of {1}", newValue.name, TransferAnimationSource.name);

0 commit comments

Comments
 (0)