drawTexture background fit screen

Hello, I have wallpaper that I draw with drawTexture, my concern is to handle different screen sizes. The size of the application is generated when the user opens the web page (compared to the size of the screen) it is necessary that the images in full screen have the right size. I find some code with Matrix4x4 but i dont have any goo result.
I just want that image full size in 1080x1920 screen same as 1100 or other resolution …

When you draw the texture, it asks for a Rect.

This gives the texture its position and its width and height.

Replace the values of width and height with Screen.width and Screen.height respectively.

Example code:

var yourtexture : Texture2D

function OnGUI(){
     GUI.DrawTexture (Rect (0, 0, Screen.width, Screen.height), yourtexture);

The GUI.DrawTexture function has a few more handles that allow you to adjust how it scales and the like. Here is a link the to literature :


The reason this scale is because Screen.width, and Screen.height are read only values of the current screen size being used by unity.

GUI.DrawTexture(Rect(Screen.width *(1f/6.55f),Screen.height *(0.1f/6.3f),Screen.width * (4.8f/6.55f), Screen.height *(0.85f/6.3f)), aTexture, ScaleMode.ScaleToFit, true, 10.0f); //java script

GUI.DrawTexture(new Rect(Screen.width *(1f/6.55f),Screen.height *(0.1f/6.3f),Screen.width * (4.8f/6.55f), Screen.height *(0.85f/6.3f)), aTexture, ScaleMode.ScaleToFit, true, 10.0f); //c#

this will adjust the all GUI what ever the screen reslotion.if it sloved your problem means do not forget to upvote

Fixed with this code.

			float horizRatio = Screen.width / 1000f;
			float vertRatio = Screen.height / 700f;
			Vector3 vect = new Vector3 (0f, 0f, 0f);
			Vector3 vect1 = new Vector3 (horizRatio*1f, vertRatio*1f, 1f);
			GUI.matrix = Matrix4x4.TRS (vect, Quaternion.identity, vect1);

			if(s_help_menu == "sauvegarde"){
				GUI.DrawTexture(new Rect(0, 0, save_helpscreen.width, save_helpscreen.height), save_helpscreen);
			}else if(s_help_menu == "creation"){
				GUI.DrawTexture(new Rect(0, 0, create_helpscreen.width, create_helpscreen.height), create_helpscreen);
			}else if(s_help_menu == "librairie"){
				GUI.DrawTexture(new Rect(0, 0, librari_helpscreen.width, librari_helpscreen.height), librari_helpscreen);
			}else if(s_help_menu == "none"){
				GUI.DrawTexture(new Rect(0, 0, acceuil_helpscreen.width, acceuil_helpscreen.height), acceuil_helpscreen);
			GUI.skin = customSkinMenusLeftSide;
			if(GUI.Button(new Rect(8f, Screen.height-8f-110f, 55f, 55f), i_close_help)){
				b_help_mode = false;