x


imaged text button

i want to make a imaged/labeled button. image - text, what is i need to use?

more ▼

asked Mar 29, 2011 at 03:24 PM

bisaniyehocam gravatar image

bisaniyehocam
161 110 84 97

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

2 answers: sort voted first

You could publish the GUIContent it would use. This allow you to set text, an image and a tooltip. If you don't want to use text or tooltip, just leave them out.

var buttonContent : GUIContent;

function OnGUI() { if (GUILayout.Button(buttonContent)) { // Handle the press } }

If you rather want to make a button with a custom style, you could either make a new style in a GUISkin or define the style directly on the script.

var buttonStyle : GUIStyle; var buttonContent : GUIContent;

function OnGUI() { if (GUILayout.Button(buttonContent, buttonStyle)) { // Handle the press } }

Or with a custom skin/style:

var customSkin : GUISkin; var buttonStyle : String = "button"; var buttonContent : GUIContent;

function OnGUI() { GUI.skin = customSkin; if (GUILayout.Button(buttonContent, buttonStyle)) { // Handle the press } }

more ▼

answered Mar 29, 2011 at 03:37 PM

Statement gravatar image

Statement
26.2k 76 114 252

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

var btnTexture : Texture;

function OnGUI() { if (GUI.Button(Rect(10,10,50,50), btnTexture)) { Debug.Log("Clicked the button with an image"); } }

more ▼

answered Mar 29, 2011 at 03:28 PM

robertmathew gravatar image

robertmathew
586 99 80 94

(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:

x1369
x398
x247
x26

asked: Mar 29, 2011 at 03:24 PM

Seen: 2222 times

Last Updated: Mar 29, 2011 at 03:24 PM