Put UI image to Grid Layout Group Unity C#

2019-07-29 05:07发布

问题:

I got trouble put the UI image inside Grid Layout Group in Unity.

This What happen. Check the link below.

  1. [IMG] http://i65.tinypic.com/fp2dly.jpg [/IMG]

  2. [IMG] http://i65.tinypic.com/2iudlxe.jpg [/IMG]

Whatever i have done change the Grid Layout Group Component : cell size value, spacing. It end with the same result like the url pic above with image gameobject cut at left side. The image gameobject size did not fix the content from the grid layout group.

When i try to scroll it, it end with same result.

Any idea ?

Thanks

回答1:

I found the solution myself,

Read this :

http://docs.unity3d.com/ScriptReference/Transform.SetParent.html

example :

childx.transform.SetParent (parentx.gameObject.transform,false);

it solve the problem