In our UI we have a set of UIToggles, let's say 2 of them, which show or hide sub-options. They are in their own group. So enabling one will disable the other.
Enabling a certain toggle will show a kind of sub-ui. This part of the UI also has UIToggles (in their own group). The "nesting" I speak of here is not a physical parent-child relationship of these toggles. Just that some parts are controlled (hidden/shown) by the "parent" UIToggles.
The issue I'm running into is with UIToggle's Set(bool state). When I click on a parent check-box, it will set that one as checked. And it will set the other one to be unchecked. Doing so will trigger a routine to hide the children UIToggles.
This leads to a nullpointer exception in the following section within UIToggle (Line 177 onward):
for (int i = 0, imax = list.size; i < imax; ++i)
{
UIToggle cb = list[i];
if (cb != this && cb.group == group) cb.Set(false);
}
The case is that imax is initialized to a value where all UIToggles were still visible. Parents and the active parent's children toggles included. However, the updates cause the list to be modified (somehow, I'm unclear on the call order) leaving it with less items (after all, some of them were made invisible). So list.size is lower inside the loop than the value imax was initialized to. And this will cause a problem with cb being null at some point.
I fear the answer is going to point at me, but could this be a problem/unforeseen circumstance on the NGUI side of the equation. Or am I simply trying to do something I really shouldn't do?
If necessary I could try and extract a simple stand-alone example, should the description not be clear.