- Home /
Is it possible to take an image and have the GUI box fit to the size of the image?
Instead of having the image compressed to the borders of the GUI? Do I have to script it?
Comment
Answer by KiraSensei · Jun 25, 2013 at 07:08 PM
I think you'll need to script it : doc
You can create it with a Rect that has the dimensions of the texture :
var texture:Texture2D;
var x:float;
var y:float;
var coeff:float = 1.0f;
function OnGUI() {
GUI.Box( Rect(x, y, texture.width*coeff, texture.height*coeff, texture));
}
You can use the var "coeff" to adapt the size of your box without stretching the texture in one specific dimension.
NB : I didn't test the code :)