- Home /
This question was
closed Apr 05, 2014 at 08:47 AM by
Team_26 for the following reason:
Duplicate Question
Question by
Team_26 · Apr 03, 2014 at 07:36 PM ·
guiresizefull screenmaximize
GUITexture size and full screen
Hi! I've got some GUITextures in my scene, but when I build the game and run it with the full screen, these GUITextures are in incorrect scale... How can I resize them when the full screen option is on?
Comment
You could give the textures a scale, and modify that during runtime.
private const float defaultScale = 1.0f;
private float myScale;
public Texture myTexture;
void Start()
{
myScale = defaultScale;
}
void OnGUI()
{
if (Screen.fullScreen)
{
myScale = 2.0f; // Whatever you'd like.
}
else
{
myScale = defaultScale;
}
GUI.DrawTexture(new Rect(16, 16, myTexture.width * myScale, myTexture.height * myScale), myTexture);
}
Answer by koray1396 · Apr 03, 2014 at 07:46 PM
you need to set position, rotation and scale values of GUITexture to 0. after that you can fit like the following;
int screenWidth;
int screenHeight;
GUITexture someGui;
void Start(){
screenWidth = Screen.width;
screenHeight = Screen.height;
someGui.pixelInset = new Rect(left, top, width, height);
}
note that you need to define left, top, width and height accordingly with screen height and width. for example,
someGui.pixelInset = new Rect(screenWidth * 0,1f, screenHeight * 0,2f, screenWidth * 0,5f, screenWidth * 0,1f);
hope this helps.
Follow this Question
Related Questions
Resize Gui 1 Answer
Best way to do GUI related stuff? 1 Answer
Textarea rezing in height by text 1 Answer
Gui Resize 1 Answer
Fix Resizing For GUI Label? 1 Answer