Author Topic: Dynamically creating tabs  (Read 3152 times)

cipherZero

  • Guest
Dynamically creating tabs
« on: December 11, 2013, 01:47:29 AM »
Hello everyone
what I'm trying to accomplish here is to create a tab table which can be managed externally. Right now I'm using XML to create a tree structure of nodes, which looks something like this:

root
  ⌊ Hong Kong
      ⌊ Causeway Bay
      ⌊ Kowloon Tong
      ⌊ Sha Tin
      ⌊ Kwai Fong
      ⌊ Wong Tai Sin
  ⌊ Japan
      ⌊ Tokyo
      ⌊ Osaka
      ⌊ Okinawa
      ⌊ Tokohama
  ⌊ England and Wales
      ⌊ Oxford
      ⌊ Cardiff
      ⌊ London
          ⌊ Lancaster Gate
          ⌊ Westminster
          ⌊ Knightsbridge
      ⌊ Bath
      ⌊ Salisbury

I created a perfab which is called tabContentPrefab, this prefab is responsible for creating rows inside the tab table. I have another prefab called tabPrefab, which is responsible for creating the tab itself.
Currently I am able to traverse all nodes and put them all inside a single row (that means only 1 tabContentPrefab), and the tab themselves are not "created" structurally like what the tree looks (like above).

Ultimately I want to achieve a dynamic tab table in which the whole structure is created at the start, including all children. The default "selected" tab will be the first child of each "branch". So the "default" look of the tab table should have 3 rows, with "Hong Kong" and "Causeway Bay" selected. When I select "England and Wales" then "London", an extra row will be created at real time and have "Lancaster Gate" selected as default.

Any idea or help will be greatly appreciated

ps. forgot the mention that I'm using Unity 3.5.7f6 and NGUI 2.6.4
« Last Edit: December 11, 2013, 01:55:57 AM by cipherZero »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Dynamically creating tabs
« Reply #1 on: December 12, 2013, 02:15:58 AM »
What you provided as an example looks to me like a tree view, not tabs. Easiest way to do this would be to instantiate labels under a game object, positioning them yourself in order to offset them correctly.

That said, 2.6.4 is very old, and I can only support the latest of the 3.X cycle, which is currently 3.0.7.