newman55/unity-mod-manager

UI.PopupToggleGroup does not work as expected

WhistleWiz opened this issue · 4 comments

Hello, I got an issue reported on my mod where a user was unable to select an option from UnityModManager.UI.PopupToggleGroup.

After trying a lot of changes to my own code, I realised the issue was from UMM.

In the mod options, I display a list of configurations, and it has a popup to add more to each entry (so basically, a list of lists). Those popups can often have the same options available in multiple entries (for example, red green and blue variants all being combined with light and dark greys), and when this happens UMM can't select options correctly. Below is my test with an attempt at making each popup unique (adding the index of the entry to each list), and the issue stopped happening.

image

Without that 26 in there (making those 3 popups have the exact same options), all of them change the first popup only. Similarly, the option selection window always has the first entry selected. When the popup options are unique, no such issue happens.

Here's the exact code: https://github.com/WhistleWiz/dv-car-changer/blob/31c776c60a4d26f1d46688ab532d7bc8cae4042a/CarChanger.Game/Settings.cs#L153

Going back to this, I ended up looking at the overloads and noticed the parameter unique.

Replacing the line I linked above with UnityModManager.UI.PopupToggleGroup(ref selected, configs, $"Installed changes for {config.LiveryName}", index); seems to work too. Anywhere with documentation on these UI commands?

The documentation is only what you see in the code, but it is not complete.

PopupToggleGroup searches for pop-ups by title and values or by title and unique number. If all the parameters are the same, they will use the same pop-up window at all.
It's enough just to have a unique title to make everything work, a unique number as a spare option. It also does not support value flags. I'll add this to the documentation.

I guess it's a performance saving measure?

Having only done Inspector GUIs before, there's a suprising lack of premade stuff on Unity's side for normal GUIs. I don't need flags in my case but yeah that'd be something convenient, I guess a simple workaround of displaying everything as a checkbox could work.

I added 2 function UI.ToggleMulti and UI.PopupToggleMulti. They only work with bits.