Content Size Fitter and Anchors / UI Scaling?

Hi All,

I’m creating a complex GUI using the new uGUI in Unity4.6, but I have a question about the Content Size Fitter component.

I’ve been using Horizontal/Vertical Layout Group components, Layout Element components, and Content Size Fitter components to get the GUI just right, but I have a problem with UI scaling across various screen aspects.

What I’d like to have is a GUI that is proportionally the same across all screen aspects and resolutions. That is, I want the GUI to occupy the same percentage of the screen area no matter what the aspect or the resolution.

To accomplish this in uGUI, I usually just ensure that the anchors of the object are set to the four corners of the object. Unity then magically takes care of the scaling for me when things are setup this way.

… UNLESS, you have a Content Size Fitter component. When you have a Content Size Fitter, it looks like Unity just ignores the anchors and doesn’t scale like I expect.

Here is an example from my Unity IDE.
This is the 16x9 aspect. Everthing is great. The panel with the Content Size Fitter takes up the entire vertical space of the screen as I want.

34626-16x9_aspect.png

This is the 5x4 aspect. The panel on the left scaled correctly, but the panel on the right with the Content Size Fitter didn’t scale. It is now smaller than the vertical size of the screen.

34627-5x4_aspect.png

Is there something I can do about this?

I really want to have a UI that scales and I really want to use the Content Size Fitter to help with layout. Can I do this?

If not, is there another approach here that I’m really supposed to be using …

Any help would be appreciated.

give this a try

I think you might want to go to your main canvas, go to the canvas scaler component and set it to “Scale with screen size.” Then play around with the match. for me I have to set it to 1 (all the way to the right).