Author Topic: UITable  (Read 52463 times)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
UITable
« on: November 23, 2013, 04:37:40 AM »
Overview

UITable is a helper script that lets you easily arrange widgets into a variable cell size grid. If you're familiar with a HTML tables, it's quite similar. It can be used both at edit time as well as run-time. If you want fixed size cells, consider using the more performant UIGrid instead.



To use UITable, select a panel, right-click anywhere in the scene view, and choose the Table from the [/b]Create menu. You may also simply attach the UITable component to any empty game object.

A table always extends toward the right first. The number of Columns controls how many columns there will be in a table before a new line will be started. The line will either be above or below the previous, based on the Direction field.

By default, the Table will simply reposition all of its children, and the order will be the order that the children happen to have been created. If you want to change this and sort them in a specific order, you can name them alphabetically ("001", "002", "003", etc), and check the Sorted checkbox. Doing so will make the Table sort them in order first before adjusting their position.

Lastly, if you want to keep the spacing left by invisible (disabled) children, turn off the Hide Inactive flag. By default this flag is on, and invisible children are simply ignored.

You can add padding in between of cells by modifying the Padding field.

Note that each child's pivot point matters. If the table's children all have center-based pivot points, they will appear to be centered within the table. If they have a top-left pivot, they will appear to be based in top-left corners of the table's cells, and so on. It's best to always work with cell items that have matching pivot points.

Pro-Tip

The table is useful for positioning things at run-time, but you can also execute it at Edit time. Simply right-click it and choose the Execute option. You can then safely delete the component if you don't need it.



Pro-Tip #2

TweenScale operations on the table's children can notify the table, causing it to reconsider its cell dimensions, thus pushing others out of the way as needed. You can create foldable areas this way like in the Quest Log example provided with NGUI.

Class Documentation

http://tasharen.com/ngui/docs/class_u_i_table.html

If you have a question regarding this component or would like me to clarify something, just post a reply here.
« Last Edit: December 10, 2013, 10:16:10 AM by ArenMook »

Isamson

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 52
    • View Profile
Re: UITable
« Reply #1 on: December 03, 2013, 03:41:05 PM »
I've started working with the table and it's really useful. I'm trying to create a something like the objective panel that opens and closes. So far, I can dynamically create all the objectives and put them in the table where they get repositioned. I'm implementing a toggle that will allow only 1 description to open at a time (not a problem).

The problem I'm experiencing is that if there are enough objectives, it's possible that some of them will be positioned outside the screen. I'm wondering if there is a way to get the size of the table? This would allow me to compare that size to the panel size and add a scroll bar when needed.
Unity 4.5.3f
NGUI 3.7.0

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITable
« Reply #2 on: December 03, 2013, 06:19:04 PM »
You can calculate the size of the table using NGUIMath.Calculate series of functions.

pretender

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 155
    • View Profile
Re: UITable
« Reply #3 on: December 15, 2013, 03:47:59 AM »
Is it possible to arrange gameobjects like cube with grid or table scripts?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITable
« Reply #4 on: December 15, 2013, 08:09:43 AM »
Grid -- yes.

pretender

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 155
    • View Profile
Re: UITable
« Reply #5 on: December 15, 2013, 08:21:25 AM »
great, it works

jinsediaoying

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UITable
« Reply #6 on: January 16, 2014, 05:38:33 AM »
Is there any option to change the anchor point of the Table and the Grid?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITable
« Reply #7 on: January 17, 2014, 12:33:18 AM »
No, the scripts are kept simple for a reason -- you should make a copy and modify them to suit your needs better.

Fractalbase

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Re: UITable
« Reply #8 on: June 16, 2014, 09:12:08 PM »
Does usage of UITable require Panels?  I'm attempting to use nested tables with 2 text boxes, a text field, and a sprite, and the ngui items don't seem to work with the uitable (no 'locking' of ui items to table columns).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITable
« Reply #9 on: June 17, 2014, 02:13:53 PM »
Nesting tables is not a good idea as there is no way to guarantee that the child table will update before the parent, and any changes to the child will affect the parent. Stick to one table.

matteo.piccioni

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: UITable
« Reply #10 on: June 23, 2014, 04:14:29 AM »
Hello,
I am evaluating to switch to unity to build my Android and iPhone app and I found that NGUI is really good for my needs
I have a question for the last obstacle I have
In my app I should have an Indexed UITableView with sections and search textfield...populated by a list of about 2 thousand items from database (each row with image, text and descriptions)
UITable is able to achieve my goal ?
Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITable
« Reply #11 on: June 24, 2014, 05:00:05 AM »
UITable is like an HTML table. It's expensive, and resizes the cells based on their content.

For a table view, simply create a prefab out of a single row, then instantiate this row repeatedly to create your UI. You can position each instance yourself, or use UIGrid.

Also note that instantiating 2000 rows is going to hurt your performance. It's better to instantiate pages, or use the endless scroll view that comes with NGUI, instantiating only partial content at a time.

matteo.piccioni

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: UITable
« Reply #12 on: June 26, 2014, 03:32:25 AM »
Thanks for the tips

PoN

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 111
    • View Profile
Re: UITable
« Reply #13 on: September 17, 2014, 03:08:58 AM »
Aren could help me pls,

I would like my items with different height in table object with UITable component,  align by bottom bound, how to do that ?

thanks
Worked on Doc&DogAge Of Fury 3D. Actually working on WarMach.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITable
« Reply #14 on: September 17, 2014, 01:26:03 PM »
Change the table to use that kind of a pivot, and use a bottom pivot on your widgets as well.