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

Commit

Permalink
Fix IndexOutOfRangeException when merge-exporting assets unrelated to…
Browse files Browse the repository at this point in the history
… any objects
  • Loading branch information
benediktwerner committed Feb 16, 2021
1 parent 4db39e5 commit 32fb453
Showing 1 changed file with 43 additions and 34 deletions.
77 changes: 43 additions & 34 deletions AssetStudioGUI/AssetStudioGUIForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,27 +1356,26 @@ private void exportObjectswithAnimationClipMenuItem_Click(object sender, EventAr

private void ExportObjects(bool animation)
{
if (sceneTreeView.Nodes.Count > 0)
if (sceneTreeView.Nodes.Count == 0)
{
var saveFolderDialog = new OpenFolderDialog();
if (saveFolderDialog.ShowDialog(this) == DialogResult.OK)
StatusStripUpdate("No Objects available for export");
return;
}

var saveFolderDialog = new OpenFolderDialog();
if (saveFolderDialog.ShowDialog(this) == DialogResult.OK)
{
var exportPath = saveFolderDialog.Folder + "\\GameObject\\";
List<AssetItem> animationList = null;
if (animation)
{
var exportPath = saveFolderDialog.Folder + "\\GameObject\\";
List<AssetItem> animationList = null;
if (animation)
animationList = GetSelectedAssets().Where(x => x.Type == ClassIDType.AnimationClip).ToList();
if (animationList.Count == 0)
{
animationList = GetSelectedAssets().Where(x => x.Type == ClassIDType.AnimationClip).ToList();
if (animationList.Count == 0)
{
animationList = null;
}
animationList = null;
}
ExportObjectsWithAnimationClip(exportPath, sceneTreeView.Nodes, animationList);
}
}
else
{
StatusStripUpdate("No Objects available for export");
ExportObjectsWithAnimationClip(exportPath, sceneTreeView.Nodes, animationList);
}
}

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

private void ExportMergeObjects(bool animation)
{
if (sceneTreeView.Nodes.Count > 0)
if (sceneTreeView.Nodes.Count == 0)
{
StatusStripUpdate("No Objects available for export");
return;
}

var gameObjects = new List<GameObject>();
GetSelectedParentNode(sceneTreeView.Nodes, gameObjects);

if (gameObjects.Count == 0)
{
var gameObjects = new List<GameObject>();
GetSelectedParentNode(sceneTreeView.Nodes, gameObjects);
var saveFileDialog = new SaveFileDialog();
saveFileDialog.FileName = gameObjects[0].m_Name + " (merge).fbx";
saveFileDialog.AddExtension = false;
saveFileDialog.Filter = "Fbx file (*.fbx)|*.fbx";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
var exportPath = saveFileDialog.FileName;
List<AssetItem> animationList = null;
if (animation)
StatusStripUpdate("No Object can be exported.");
return;
}

var saveFileDialog = new SaveFileDialog();
saveFileDialog.FileName = gameObjects[0].m_Name + " (merge).fbx";
saveFileDialog.AddExtension = false;
saveFileDialog.Filter = "Fbx file (*.fbx)|*.fbx";
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
var exportPath = saveFileDialog.FileName;
List<AssetItem> animationList = null;
if (animation)
{
animationList = GetSelectedAssets().Where(x => x.Type == ClassIDType.AnimationClip).ToList();
if (animationList.Count == 0)
{
animationList = GetSelectedAssets().Where(x => x.Type == ClassIDType.AnimationClip).ToList();
if (animationList.Count == 0)
{
animationList = null;
}
animationList = null;
}
ExportObjectsMergeWithAnimationClip(exportPath, gameObjects, animationList);
}
ExportObjectsMergeWithAnimationClip(exportPath, gameObjects, animationList);
}
}

Expand Down

0 comments on commit 32fb453

Please sign in to comment.