From a5240c92b78e493a60a2728715b6ae30a5acf44d Mon Sep 17 00:00:00 2001 From: kimsama Date: Tue, 17 May 2016 15:14:01 +0900 Subject: [PATCH] Fixed index out of range error which can be occur when one of the worksheet was removed. --- .../ExcelPlugin/Editor/ExcelMachineEditor.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Assets/QuickSheet/ExcelPlugin/Editor/ExcelMachineEditor.cs b/Assets/QuickSheet/ExcelPlugin/Editor/ExcelMachineEditor.cs index 8ba91b5..24fc956 100644 --- a/Assets/QuickSheet/ExcelPlugin/Editor/ExcelMachineEditor.cs +++ b/Assets/QuickSheet/ExcelPlugin/Editor/ExcelMachineEditor.cs @@ -106,6 +106,16 @@ Set a folder under the 'Assets' folder! \n { // reopen the excel file e.g) new worksheet is added so need to reopen. machine.SheetNames = new ExcelQuery(machine.excelFilePath).GetSheetNames(); + + // one of worksheet was removed, so reset the selected worksheet index + // to prevent the index out of range error. + if (machine.SheetNames.Length <= machine.CurrentSheetIndex) + { + machine.CurrentSheetIndex = 0; + + string message = "Worksheet was changed. Check the 'Worksheet' and 'Update' it again if it is necessary."; + EditorUtility.DisplayDialog("Info", message, "OK"); + } } }