Skip to content

Commit

Permalink
Fix: Error when an option menu is loaded on menu open (#480)
Browse files Browse the repository at this point in the history
Fixed `InvalidOperationException` for menu options
  • Loading branch information
Metious committed Oct 2, 2023
1 parent 0c0c45c commit 9eee31a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Nautilus/Options/Attributes/OptionsMenuBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ public override void BuildModOptions(uGUI_TabbedControlsPanel panel, int modsTab
}
}
}
base.BuildModOptions(panel, modsTabIndex, Options);

base.BuildModOptions(panel, modsTabIndex, options);
}

/// <summary>
Expand Down
8 changes: 7 additions & 1 deletion Nautilus/Options/ModOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ public bool RemoveItem(string id)

internal void AddOptionsToPanel(uGUI_TabbedControlsPanel panel, int modsTabIndex)
{
BuildModOptions(panel, modsTabIndex, Options);
/*
* Since Subnautica runs on a very old CLR, iterating on a list that is changed in the loop throws an exception.
* To prevent the mistake of calling RemoveItem or AddItem while iterating on the Options property, we pass a copy of
* The Options property.
*/
var options = Options.ToList();
BuildModOptions(panel, modsTabIndex, options);
}

/// <summary>
Expand Down

0 comments on commit 9eee31a

Please sign in to comment.