Skip to content
This repository was archived by the owner on Jan 21, 2023. It is now read-only.

Commit 32fb453

Browse files
Fix IndexOutOfRangeException when merge-exporting assets unrelated to any objects
1 parent 4db39e5 commit 32fb453

File tree

1 file changed

+43
-34
lines changed

1 file changed

+43
-34
lines changed

AssetStudioGUI/AssetStudioGUIForm.cs

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,27 +1356,26 @@ private void exportObjectswithAnimationClipMenuItem_Click(object sender, EventAr
13561356

13571357
private void ExportObjects(bool animation)
13581358
{
1359-
if (sceneTreeView.Nodes.Count > 0)
1359+
if (sceneTreeView.Nodes.Count == 0)
13601360
{
1361-
var saveFolderDialog = new OpenFolderDialog();
1362-
if (saveFolderDialog.ShowDialog(this) == DialogResult.OK)
1361+
StatusStripUpdate("No Objects available for export");
1362+
return;
1363+
}
1364+
1365+
var saveFolderDialog = new OpenFolderDialog();
1366+
if (saveFolderDialog.ShowDialog(this) == DialogResult.OK)
1367+
{
1368+
var exportPath = saveFolderDialog.Folder + "\\GameObject\\";
1369+
List<AssetItem> animationList = null;
1370+
if (animation)
13631371
{
1364-
var exportPath = saveFolderDialog.Folder + "\\GameObject\\";
1365-
List<AssetItem> animationList = null;
1366-
if (animation)
1372+
animationList = GetSelectedAssets().Where(x => x.Type == ClassIDType.AnimationClip).ToList();
1373+
if (animationList.Count == 0)
13671374
{
1368-
animationList = GetSelectedAssets().Where(x => x.Type == ClassIDType.AnimationClip).ToList();
1369-
if (animationList.Count == 0)
1370-
{
1371-
animationList = null;
1372-
}
1375+
animationList = null;
13731376
}
1374-
ExportObjectsWithAnimationClip(exportPath, sceneTreeView.Nodes, animationList);
13751377
}
1376-
}
1377-
else
1378-
{
1379-
StatusStripUpdate("No Objects available for export");
1378+
ExportObjectsWithAnimationClip(exportPath, sceneTreeView.Nodes, animationList);
13801379
}
13811380
}
13821381

@@ -1392,28 +1391,38 @@ private void exportSelectedObjectsmergeWithAnimationClipToolStripMenuItem_Click(
13921391

13931392
private void ExportMergeObjects(bool animation)
13941393
{
1395-
if (sceneTreeView.Nodes.Count > 0)
1394+
if (sceneTreeView.Nodes.Count == 0)
1395+
{
1396+
StatusStripUpdate("No Objects available for export");
1397+
return;
1398+
}
1399+
1400+
var gameObjects = new List<GameObject>();
1401+
GetSelectedParentNode(sceneTreeView.Nodes, gameObjects);
1402+
1403+
if (gameObjects.Count == 0)
13961404
{
1397-
var gameObjects = new List<GameObject>();
1398-
GetSelectedParentNode(sceneTreeView.Nodes, gameObjects);
1399-
var saveFileDialog = new SaveFileDialog();
1400-
saveFileDialog.FileName = gameObjects[0].m_Name + " (merge).fbx";
1401-
saveFileDialog.AddExtension = false;
1402-
saveFileDialog.Filter = "Fbx file (*.fbx)|*.fbx";
1403-
if (saveFileDialog.ShowDialog() == DialogResult.OK)
1404-
{
1405-
var exportPath = saveFileDialog.FileName;
1406-
List<AssetItem> animationList = null;
1407-
if (animation)
1405+
StatusStripUpdate("No Object can be exported.");
1406+
return;
1407+
}
1408+
1409+
var saveFileDialog = new SaveFileDialog();
1410+
saveFileDialog.FileName = gameObjects[0].m_Name + " (merge).fbx";
1411+
saveFileDialog.AddExtension = false;
1412+
saveFileDialog.Filter = "Fbx file (*.fbx)|*.fbx";
1413+
if (saveFileDialog.ShowDialog() == DialogResult.OK)
1414+
{
1415+
var exportPath = saveFileDialog.FileName;
1416+
List<AssetItem> animationList = null;
1417+
if (animation)
1418+
{
1419+
animationList = GetSelectedAssets().Where(x => x.Type == ClassIDType.AnimationClip).ToList();
1420+
if (animationList.Count == 0)
14081421
{
1409-
animationList = GetSelectedAssets().Where(x => x.Type == ClassIDType.AnimationClip).ToList();
1410-
if (animationList.Count == 0)
1411-
{
1412-
animationList = null;
1413-
}
1422+
animationList = null;
14141423
}
1415-
ExportObjectsMergeWithAnimationClip(exportPath, gameObjects, animationList);
14161424
}
1425+
ExportObjectsMergeWithAnimationClip(exportPath, gameObjects, animationList);
14171426
}
14181427
}
14191428

0 commit comments

Comments
 (0)