Author Topic: Bug with UIToggleObjects  (Read 1990 times)

Quarkism

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
Bug with UIToggleObjects
« on: November 25, 2013, 09:26:57 PM »
I have a 3 tab view using UIToggleObjects. The first toggle button has an true initial state, the other two are false. When the view awakens I see the first and second tab overlapping.

I was able to fix the issue with this hackish fix.

public void Toggle ()
   {
   bool val = UIToggle.current.value;

        // hackish fix to get my tab view to work
        if (!val && IgnoreIfFalse)
            return;

      if (enabled)
      {
         for (int i = 0; i < activate.Count; ++i)
            Set(activate, val);

         for (int i = 0; i < deactivate.Count; ++i)
            Set(deactivate, !val);
      }
   }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Bug with UIToggleObjects
« Reply #1 on: November 26, 2013, 03:36:14 AM »
I am not sure I understand the issue... tabs overlapping?

Quarkism

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
Re: Bug with UIToggleObjects
« Reply #2 on: November 26, 2013, 10:15:20 PM »
I am using a UIToggleObjects to create a tab view. I have three tab buttons and three container objects. The container objects have panels and child ui controls. The intended use is that only one container is open at a single instance. The first tab button has the first tab container as "activate" and the other two as "deactivate". The other two tabs follow similar logic.

When I play and view the screen in question tab 2 and tab 1 are both open. If I press the tab buttons the issue corrects itself.

My hunch was that the UIToggleObjects OnToggle method was running simultaneously for each of the three buttons. Following my hunch I made a fix to make sure only one of the methods was executed. It resolved the issue.

That said, my fix is not an elegant fix, but it is the best I could do without diving into the heart of NGUI.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Bug with UIToggleObjects
« Reply #3 on: November 27, 2013, 12:24:28 AM »
You don't need to specify both activate and deactivate objects. Just one is enough. Have each toggle only specify their own tab as "activate". That's also what I did in the Tabs Example that comes with NGUI.