- Home /
Question by
Levantez · Jun 12, 2012 at 10:03 AM ·
guitextureresourceresources.loadall
GUI layout Label Dimension issue
I have 2+ GUI textures that have different dimension. I wanted them to display as full image, but image2 got clipped like this,
Here's the code
private Texture2D[] pages;
private int currentPage;
private Rect guiScreenRect;
protected void OnGUI()
{
if(isActivate)
{
float divider = 0.5f;
// left top width height confine to 0-1 pages[currentPage].height*divider
guiScreenRect = new Rect(0.0f,0.0f,1.0f*divider,0.9f*divider);
guiScreenRect.x *= Screen.width;
guiScreenRect.width *= Screen.width;
guiScreenRect.y *= Screen.height;
guiScreenRect.height *= Screen.height;
GUILayout.BeginArea(guiScreenRect);
GUILayout.Label(pages[currentPage]);
GUILayout.EndArea();
}
}
public void LoadResourcesBaseonID(string refID)
{
currentPage = 0;
int ID = int.Parse(refID);
string bookTitle = BookData.m_BookData[ID].GetTitle();
pages = Resources.LoadAll("BookPages/" + bookTitle, typeof(Texture2D)).Cast<Texture2D>().ToArray();
}
Page01.jpg
(107.8 kB)
Page02.jpg
(100.9 kB)
Comment
Couldn't this be done easily if you just used GUI.DrawTexture()? For example, for the left page, GUI.DrawTexture(new Rect(0, 0, Screen.width / 2, Screen.height), leftPageTexture);
.
Your answer
![](https://koobas.hobune.stream/wayback/20220613072647im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Problem With GUI Circle Thickness 0 Answers
9-Sliced Legacy GUI 2 Answers
unity make a skin/texture to a character like the robot from the fps tutorial 1 Answer
iTween and texture problem 0 Answers
The Game Over creating with audio? 1 Answer