Can anyone explain why, in the editor I get:

enter image description here

while, on my Galaxy S6, I get:

enter image description here

My Panel UI element (which is the parent) has the GridLayoutGroup component, as well as the ContentSizeFitter. The child elements have a LayoutElement component with a FlexibleWidth/Height of 120 and all anchors are set to stretch in all directions.

The Canvas is set to Scale with Screen size, with a reference res of 320x480 and screen mode is to match height.

Regardless of the amount of squares (which is dynamic) the editor perfectly resizes child elements within the parent, but my device makes them tiny. I'm really confused.

There is no setting of sizes or anchors within the script, purely an instantiate and an assignment of parent, like so:

    for(int i=0; i < amount; i++)
        GameObject emptyCell = (GameObject)Instantiate(emptyCellObject);
        emptyCell.GetComponent<RectTransform>().localPosition = new Vector3(0f, 0f, 0f);

I've also checked all docs related to: http://docs.unity3d.com/Manual/comp-UIAutoLayout.html - And even UI tutorial movies, as well as some blog posts about the 'new' UI tools, but nothing changes the dimensions on the physical device, and seems to change nothing in the editor as that remains the same.

I'm sure I'm doing something silly, but I've exhausted all avenues and was hoping someone had come across this oddity previously.


1 Answer 1


Figured this out in the end. Was due to the parent object scaling the child elements (based upon screen space I'm assuming), which was counter-productive in this instance. My work around:

emptyCell.GetComponent<RectTransform>().localScale = new Vector3(1f, 1f, 1f);

...was to manually override the scaling myself and it works lovely on all devices now. Hope this helps someone out in the future :)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .