diff --git a/Editor/Assets/InventoryPresetEditor.cs b/Editor/Assets/InventoryPresetEditor.cs index f379a10..8f309a0 100644 --- a/Editor/Assets/InventoryPresetEditor.cs +++ b/Editor/Assets/InventoryPresetEditor.cs @@ -401,7 +401,7 @@ public void OnEnable() if (remainingToggles.Count > 0) { // Set the item to use the first remaining toggle if it has none assigned. - if (item.Item == null) + if (item.Item == null || !allToggles.Contains(item.Item)) { item.Item = remainingToggles[0]; } @@ -593,7 +593,7 @@ public void OnEnable() if (remainingToggles.Count > 0) { // Set the item to use the first remaining toggle if it has none assigned. - if (item.Item == null) + if (item.Item == null || !allToggles.Contains(item.Item)) { item.Item = remainingToggles[0]; } @@ -784,7 +784,7 @@ public void OnEnable() if (remainingToggles.Count > 0) { // Set the item to use the first remaining toggle if it has none assigned. - if (item.Item == null) + if (item.Item == null || !allToggles.Contains(item.Item)) { item.Item = remainingToggles[0]; } @@ -867,7 +867,7 @@ public void OnEnable() } // Don't continue if there are no other toggles. - if (totalUsage - 1 == list.list.Count) + if (totalUsage == list.list.Count) { return; } diff --git a/Editor/Scripts/InventoryInventor.cs b/Editor/Scripts/InventoryInventor.cs index 8f9f2fd..112237a 100644 --- a/Editor/Scripts/InventoryInventor.cs +++ b/Editor/Scripts/InventoryInventor.cs @@ -561,6 +561,11 @@ Add expression parameters to the list. /* Create Expressions menu for toggles. */ + bool menuExists = false; + if (menu != null) + { + menuExists = true; + } switch (CreateMenus(out VRCExpressionsMenu inventory, items.Count)) { @@ -575,7 +580,7 @@ Add expression parameters to the list. } // Assign the Inventory menu to given menu if possible and provided. - if (menu != null) + if (menuExists && menu != null) { bool exists = false; @@ -602,6 +607,12 @@ Add expression parameters to the list. EditorUtility.DisplayDialog("Inventory Inventory", "WARNING: Inventory controls were not added to the provided menu.\n(No space is available.)", "Close"); } } + else if (menuExists) + { + avatar.expressionsMenu = inventory; + EditorUtility.SetDirty(avatar); + menu = inventory; + } EditorUtility.DisplayProgressBar("Inventory Inventor", "Finalizing", 1f); @@ -1330,10 +1341,16 @@ private void CreateMasterLayer(AnimatorController source, int itemTotal, out Lis } break; } - // Add group settings. for (int j = 0; j < items[i].EnableGroup.Length; j++) { + // Catch faulty data + if (items.IndexOf(items[i].EnableGroup[j].Item) == -1) + { + EditorUtility.DisplayDialog("Inventory Inventor", "ERROR: " + items[i].name + "\'s Enable Group has a corrupt member in Slot " + (j + 1) + ". Please reassign the member to the desired Item to fix it. The program will now abort forcefully.", "Close"); + Selection.activeObject = preset; + throw new Exception("Inventory Inventor: Corrupt member data found in " + items[i].name + "/Enable Group/Slot " + (j + 1) + "."); + } // If the group item refers to an actual toggle. if (items[i].EnableGroup[j].Item != null) switch (items[i].EnableGroup[j].Reaction) @@ -1460,6 +1477,13 @@ private void CreateMasterLayer(AnimatorController source, int itemTotal, out Lis // Add group settings. for (int j = 0; j < items[i].DisableGroup.Length; j++) { + // Catch faulty data + if (items.IndexOf(items[i].DisableGroup[j].Item) == -1) + { + EditorUtility.DisplayDialog("Inventory Inventor", "ERROR: " + items[i].name + "\'s Disable Group has a corrupt member in Slot " + (j + 1) + ". Please reassign the member to the desired Item to fix it. The program will now abort forcefully.", "Close"); + Selection.activeObject = preset; + throw new Exception("Inventory Inventor: Corrupt member data found in " + items[i].name + "/Disable Group/Slot " + (j + 1) + "."); + } // If the group item refers to an actual toggle. if (items[i].DisableGroup[j].Item != null) switch (items[i].DisableGroup[j].Reaction) @@ -1585,6 +1609,13 @@ private void CreateMasterLayer(AnimatorController source, int itemTotal, out Lis // Add group settings. for (int j = 0; j < buttons[i].ButtonGroup.Length; j++) { + // Catch faulty data + if (items.IndexOf(buttons[i].ButtonGroup[j].Item) == -1) + { + EditorUtility.DisplayDialog("Inventory Inventor", "ERROR: " + items[i].name + " has a corrupt member in Slot " + (j + 1) + ". Please reassign the member to the desired Item to fix it. The program will now abort forcefully.", "Close"); + Selection.activeObject = preset; + throw new Exception("Inventory Inventor: Corrupt member data found in " + items[i].name + "/Slot " + (j + 1) + "."); + } // If the group item refers to an actual toggle. if (buttons[i].ButtonGroup[j] != null && buttons[i].ButtonGroup[j].Item != null) switch (buttons[i].ButtonGroup[j].Reaction) diff --git a/Editor/VERSION b/Editor/VERSION index efdb8b1..32e7334 100644 --- a/Editor/VERSION +++ b/Editor/VERSION @@ -1 +1 @@ -v1.1.2 \ No newline at end of file +v1.1.3 \ No newline at end of file