x


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! :)

more ▼

asked Feb 13, 2011 at 10:46 PM

futureseeker 1 gravatar image

futureseeker 1
129 56 42 48

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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);

more ▼

answered Feb 14, 2011 at 07:38 PM

cpp_fanatic gravatar image

cpp_fanatic
47 13 10 15

GUI.DrawTexture and GUITexture are 2 different system !

Mar 06 at 06:20 AM raptorkwok
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x6082
x5041
x3689

asked: Feb 13, 2011 at 10:46 PM

Seen: 7545 times

Last Updated: Mar 06 at 06:20 AM