OverviewUITable 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-TipThe 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 #2TweenScale 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 Documentationhttp://tasharen.com/ngui/docs/class_u_i_table.htmlIf you have a question regarding this component or would like me to clarify something, just post a reply here.