- Home /
Guilayout problems with image resize
Hi all, I'm writing to ask you about the images on a unity gui. I'm using Guilayout because I think helps me a lot for organize the gui. I want to display in the upper left corner of the screen two images and one should be bigger than the other. Here's the code where iWidth and fSpace are precomputed values:
void OnGUI(){
GUI.skin = mySkin;
GUILayout.BeginArea(new Rect(10,10, iWidth + fSpace,selected_profile.height));
GUILayout.BeginHorizontal();
GUILayout.Box(selected_profile,GUILayout.Width(iWidth * 0.7F));
GUILayout.Box(selected_image_profile,GUILayout.MaxWidth(iWidth * 0.3F),GUILayout.ExpandHeight(false));
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
The problem is that the second image loose proportion and appear stretched along his heigth even if I've set the ExpandHeight to false. The first image is 230w x 276h The second is 364w x 469h
The first one looks ok even if is not perfect but the second (due to the subject of the pic that is a woman face) appeards odd.
Is there a way to keep proportion inserting an image in a unity GUI?
Comment