Author Topic: Creating tabs or redesigned interface  (Read 3816 times)

Jinfaa

  • Guest
Creating tabs or redesigned interface
« on: January 09, 2013, 02:37:45 AM »
Hello! Recently purchased and began reshaping NGUI user interface. Met with a problem, I can not do tabs. I wish that when you press the top button to change and add if necessary, buttons 5 6 7 and 8. But in order to set up the buttons on the programmatically, because the buttons have their data.
Simply put how to update the UI? Previously done in OnGui.
Attach pictures below to get an idea what I want.
Please excuse me for my english!
« Last Edit: January 09, 2013, 03:03:04 AM by Jinfaa »

Cripple

  • TNP Alpha
  • Full Member
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 117
    • View Profile
Re: Creating tabs or redesigned interface
« Reply #1 on: January 09, 2013, 03:48:54 AM »
Actually that is really easy to do.

You could have a hierarchy like this one :

      -> Tab1-UIMyCustomTab
                 -> MyButton1 (enabled)
                 -> MyButton2 (enabled)
      -> Tab2-UIMyCustomTab
                 -> MyButton3 (disabled)
                 -> MyButton4 (disabled)
      -> Tab3-UIMyCustomTab
                 -> MyButton5 (disabled)
                 -> MyButton6 (disabled)

UIMyCustomTab is a custom script with the Requirement of a BoxCollider. Override the OnClick for example which enables its children and search all component of type UIMyCustomTab on the same Hierarchy level to call a method which disables all of their children. You can also animate their alpha instead of disabling/enabling them for example.

To add Widgets at runtime you have to use this : NGUITools.AddChild(Tab1, ThePrefabOfTheWidgetToCreate);

« Last Edit: January 09, 2013, 03:59:08 AM by Cripple »
Graphicstream Dev.

Jinfaa

  • Guest
Re: Creating tabs or redesigned interface
« Reply #2 on: January 09, 2013, 06:51:06 AM »
Tell me and if I do three buttons. And in the code to identify the variables selectedTab (int). Pressing the button will be an appointment from 1 to 3, according to the button. If you press the first button that generates keys for the first tab. If clicked on the second button, then delete all the children of the panel and add new ones. Is this normal? =)