Hi,
I’m trying to stretch my buttons to fit on any resolution. According to the API, this can be done easily with a GuiTexture, but not with a texture applied to a button?
if(GUI.Button(Rect(xDistance,yDistance*3,buttonWidth,buttonHeight),optionsTexture, ScaleMode.ScaleToFit, true, 10.0F))
{
Application.LoadLevel(6);
}
Any ideas why it won’t work?
Thanks a bunch!
Try using ScaleMode.StretchToFill instead of ScaleMode.ScaleToFit.
I wrote this function as a drop-in replacement for GUI.Button(Rect,Texture2D):
bool GUIButtonTexture2D( Rect r, Texture2D t)
{
GUI.DrawTexture( r, t);
return GUI.Button( r, "", "");
}
It should have the desired minify and magnify behaviors that the original poster seeks.
Obviously, you must only call it from inside your OnGUI() function.
Button scales textures down if needed, so make your texture big enough for your max resolution.
Scaling textures up makes them ugly anyway, so large enough texture is an easy (if not ideal) solution.