Author Topic: Group of UIToggles error  (Read 1301 times)

elvess

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Group of UIToggles error
« on: August 28, 2014, 02:57:26 AM »
Hello. I have a group of UIToggle. This is 5 separate UIToggles and 1 - Check All Toggle. When I check Check All Toggle it should do something like:
   foreach (PlayerItem item in m_PlayersList)
            {
                if (!item.IsChecked)
                    item.SelectPlayerToggle.value = true;
            }

There is OnValueChange event on  item.SelectPlayerToggle. But I receive an error on the first iteration
Object reference not set to an instance of an object UIToggledObjects.Toggle () (at Assets/NGUI/Scripts/Interaction/UIToggledObjects.cs:49) - bool val = UIToggle.current.value;

Is there a way to do this by code?
Thank U

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Group of UIToggles error
« Reply #1 on: August 28, 2014, 09:08:02 PM »
How are you getting the UIToggledObjects.Toggle to trigger with UIToggle.current being null? That function is called by UIToggle's onChange notification, which is wrapped inside "current = this" section. What version of NGUI are you using?