Hey,
I have a tabbed interface for an in-game market. There are 4 tabs (UIToggle with same group index) each activating their respective UIScrollView. These scroll views contain their own set of UIToggle 's for the items being sold in the game. This works great with no problems.
What I want to do is; I want to select the first item of the related scroll view when the market tab changes. I want to set it's value to true. I tried two ways, both didn't work completely.
1. I programmed a method which finds the first item of the given category and set it's value to true. I invoked this method through the each category UIToggle's OnValueChange by hooking it through it's inspector. Upon testing it I realized the first item is accepted as the "activated" one after doing this because I can't select it anymore unless I select something else first. But it's animation doesn't play (The animation it should play when it's the activated UIToggle in the group). And it's own OnValueChange is never called.
2. I added a bool to the UIScrollView called "activateFirstItemOnEnable". I've also added it to the UIScrollViewEditor so I can see this bool in the inspector. What it does is, it calls my above mentioned method of finding and activating the first item in the UIScrollView 's OnEnable() if activateFirstItemOnEnable is true. This way the animation of the first item 's UIToggle plays nicely. But if I have selected -for example- item5, changed category, and came back to this category, item5 's dismiss animation doesn't play, it just stays with the "active" animation so it looks like both item1 and item5 are active at the same time. Also the item1 's OnValueChange is not called this way either (I want it because I refresh some labels containing the details of the selected item).
TL;DR So how can I make it so that when I enable a scroll view with a button, it's first UIToggle item get's selected, plays it's animation smoothly, invokes it's OnValueChanged method and disbles all other UIToggle's in the same group under this scroll view.
Hope it makes sense, thanks in advance for all the help!