How to do you add GUI texture using a script?and position it to the left (regardless of the reso.)

I have searched in and find out how to add it by selecting a texture and heading up to gameobject>creat other>GUI TEXTURE..But how can i do it on script? and if possible to have it positioned in the left part regardless of the Screen resolution.

I hope you can help me out! :)

Hello!

The simplest way:

Texture2D image = (Texture2D)Resources.Load("image1");

Note the follows:

  1. You should put the file called "image1.png" into the Resources folder in your project folder. Calling the Load method you should not specify the extension of your file.
  2. You can have subfolders in the Resources folder.

Link: http://unity3d.com/support/documentation/ScriptReference/Resources.html

Draw the image:

GUI.DrawTexture(new Rect(0, 0, image.width, image.height), image);