- Home /
Question by
futureseeker 1 · Feb 13, 2011 at 10:46 PM ·
guitexture
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! :)
Comment
Best Answer
Answer by cpp_fanatic · Feb 14, 2011 at 07:38 PM
Hello!
The simplest way:
Texture2D image = (Texture2D)Resources.Load("image1");
Note the follows:
- 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.
- 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);
GUI.DrawTexture
and GUITexture
are 2 different system !
Your answer
Follow this Question
Related Questions
dirty lens effect over light help 1 Answer
change bar position 1 Answer
Load an image from www and save it for offline use 0 Answers
reference Gui texture outside script 1 Answer
Null reference exception[SOLVED] 1 Answer