Hi, i am trying to place a gui texture according to screen resolution.I would place the gui texture using a zero inset in both x and y and just position it using the transform tools, so in this way it would always be positioned at the same place regarding for different screen sizes.As well i am scaling my gui texture to fit to the resolution without streching it.I would do all of these if there was an existing gui texture BUT to you gui utility rotate around pivot, as the documentation says this code will only work for a new gui texture that has drawn.So i use GUI.DrawTexture to draw my texture on screen but cannot find a way how to scale and position it regarding to screen size? If i would do this for an existing gui texture i know how to do it but how can i do it for a new created one?
Don’t confuse GUITexture with the GUI system: GUITexture (and GUIText) are scene objects (although transform properties work differently than 3D world objects), while elements of the GUI system are drawn on the fly in OnGUI. If you’re using the GUI system, a simple way to adjust GUI items to different resolutions is to scale the GUI matrix (take a look at this answer for more details). If you don’t want to scale all GUI items, however, you can scale and/or re-position the rect passed to GUI.DrawTexture. If you want to know the texture size, get its width and height properties:
public var texture: Texture2D; // the texture you want to draw
public var leftPos: float; // left coordinate
public var topPos: float; // top coordinate (0 = top of screen)
function OnGUI(){
var r: Rect = Rect(leftPos, topPos, texture.width, texture.height);
GUI.DrawTexture(r, texture);
}