Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: raydenuni on July 30, 2014, 04:34:02 PM

Title: If UIStretch is obsolete, how to size background to grid?
Post by: raydenuni on July 30, 2014, 04:34:02 PM
I would like to set the size of a UISprite to be the size of a grid with its children. It looks like UIStretch can do that, but it's deprecated in place of the anchoring system. One can't anchor a UIWidget to a grid because a grid is not itself a widget. How should I go about populating a grid and then resizing a texture to be the size of the elements in the grid?
Title: Re: If UIStretch is obsolete, how to size background to grid?
Post by: ArenMook on July 31, 2014, 10:56:09 AM
Create an invisible widget -- ALT+SHIFT+W, and attach the EnvelopContent script to it. Target the UIGrid. You can now anchor things to this invisible widget, and its bounds will be the bounds of all content underneath your grid.

Just don't make a mistake of making that widget a child of your grid or bad things will happen.