Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: jrhee on July 27, 2014, 10:33:41 PM

Title: wrapping UIGrid contents
Post by: jrhee on July 27, 2014, 10:33:41 PM
Hi Aren,

I have a horizontal UIGrid with a column limit of 3. I'd like to have the grid contents wrap onto additional rows if the combined cell width exceeds the grid widget dimensions (example attached). Is this possible currently out of the box? Would like to check before scripting something.

(https://dl.dropboxusercontent.com/u/442480/ngui_example.jpg)

Thanks!
Title: Re: wrapping UIGrid contents
Post by: ArenMook on July 27, 2014, 11:25:31 PM
There is nothing in NGUI that would facilitate this kind of functionality -- you would need to code it yourself.
Title: Re: wrapping UIGrid contents
Post by: jrhee on July 28, 2014, 02:58:13 AM
Ok thanks- here's the script I came up with in case anyone's interested.

  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class UIGridWrapping : UIGrid {
  5.  
  6.         void Start()    {
  7.                 UpdateMaxPerLine ();
  8.                 base.Start ();
  9.         }
  10.  
  11.         [ContextMenu("Execute")]
  12.         public override void Reposition()       {
  13.                 UpdateMaxPerLine();
  14.                 base.Reposition ();
  15.         }
  16.  
  17.         void UpdateMaxPerLine() {
  18.                 maxPerLine = (int) (GetComponent<UIWidget>().width/cellWidth);
  19.         }
  20. }
  21.