x


Layouts with GUITextures

Hi there!

I want to create a GUI with GUIText and GUITexture. I created a simple pad in photoshop and made it to a GUITexture. Now I want to chane its width by code, it has to get the width of the screen. I also want to place GUIText always 5 Pixel left from the roght upper corner.

How could I achieve that? THX!

more ▼

asked May 11 '10 at 01:39 PM

headkit gravatar image

headkit
280 25 28 36

the important part of my question was how to place the GUI element allways 5 pixels left from the left upper corner, independent from the screen size.

Jun 11 '10 at 07:21 AM headkit
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

You don't want to use GUIText and GUITexture as they're somewhat "outdated" (I use that term loosely).

The thing you should be looking at instead is the relatively-new Unity GUI, specifically, GUI.Texture, and GUI.Label.

more ▼

answered May 11 '10 at 04:36 PM

qJake gravatar image

qJake
11.6k 43 78 161

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

You could also just create buttons and windows to your liking with each texture and then independently render them on GUI. You actually get a much better look to your GUI if you do things this way. You don't need Skins.

First in your scene create an empty game object, then attach this script to it..

in Java.

<<>>

var icon: Texture2D; //this is your texture.

function OnGUI(){
GUI.Button(Rect(10,10,100,100),GUIContent(icon)));

} //this creates a variable space in the inspector where you drag and drop your texture.

<<>>

Attach this script to your empty object, and you are done without using skins.

more ▼

answered Jun 09 '10 at 10:16 PM

khalil gravatar image

khalil
38 6 7 12

  1. He means "UnityScript" aka Javascript, not Java. -- 2. Please format your code when posting it, by hilighting it and clicking the "Code Format" button in the toolbar.
Jun 09 '10 at 10:29 PM qJake
(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:

x3689
x475
x48

asked: May 11 '10 at 01:39 PM

Seen: 2624 times

Last Updated: May 11 '10 at 01:39 PM