- Home /
Question by
FuryFight3r · Dec 28, 2016 at 12:57 PM ·
guitexture2dscaleguitexture
Scaling a 2D Texture (Image)
Hi there guys, I've been trying for a bit now, and can't seem to work it out, what I'm trying to achieve is an inventory GUI Backdrop screen, i want to make a background for the Inventory, no matter how big/small the Resolution is of the photo (Texture2D) it fills the whole screen, this is the code i am using,
function OnGUI() {
if(_display){
if(_displayInventoryScreen){
GUI.DrawTexture(_windowRect, _invBackDrop, ScaleMode.StretchToFill); // This fills Screen (I'm using this as a comparison to the equipment screen)
for(var x = 0; x < mainInventoryList.Count; x++){
if(GUI.Button(Rect(Screen.width / 2, Screen.height / 2 + (x * 60), 120, 55), GUIContent(" " + mainInventoryList[x].name, mainInventoryList[x].icon))){
}
}
}
if(_displayEquipScreen){
GUI.DrawTexture(_windowRect, _equipmentBackDrop); //This is what i want to have as a smaller image that does not cover the whole screen, i removed the 'ScaleMode.StretchToFill' to try and achieve either the same size as the resolution of the photo, or something that i can hard code in to set the scaling size, but am unsure how to size it.
}
i just want to know how i can size it to just cover a small portion of the screen, for some reason it still keeps scaling to fill the screen.
Comment