x


i want to change the texture when hover on it

var icon : Texture2D;
var icon2: Texture2D;
var icon3: Texture2D;
var change : Texture2D;
var change2: Texture2D;
var change3: Texture2D;

function OnGUI () {
      GUI.backgroundColor = Color (0, 0, 0, 0);
    //if (GUI.Button (Rect (660, 110, 200, 150), icon)) {
      if (button == active);{
       GUI.Button (Rect (660, 110, 200, 150), iconActive)
       else if(button != active);
           {
            GUI.Button (Rect (660, 110, 200, 150), icon)
           }  
       Application.LoadLevel("Islands");
    }

can any one help me on this scrip?i want the play button to change the texture when i hover on it..it can switch scene but cant change the texture..

more ▼

asked Aug 26 '10 at 07:04 AM

nicole gravatar image

nicole
21 12 15 22

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

1 answer: sort voted first

To get the button to change texture on hover you don't need any script at all. Just look into GUIStyle in the documentation. Oh, and there shouldn't be a ';' after if-else statements.

more ▼

answered Aug 26 '10 at 07:18 AM

StephanK gravatar image

StephanK
6k 40 53 93

how to adjust the GUI.style position??

Aug 26 '10 at 09:00 AM nicole

What do you mean? There is no such thing as a GUIStyle position. GUIStyle is just something that tells unity how a GUI element should look like. You can specify a GUIStyle for every element by passing it as last parameter to the function creating that element. So in your case: GUI.Button(positionRect, icon, style);

Aug 26 '10 at 12:31 PM StephanK

can give me simple code example?

Aug 27 '10 at 01:54 AM nicole

There IS no code involved besides the line I already posted in my last comment. Just read the GUI tutorial and probably you will understand.

Aug 27 '10 at 10:38 AM StephanK

solved it!thx alot:D

Aug 30 '10 at 02:14 AM nicole
(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:

x820

asked: Aug 26 '10 at 07:04 AM

Seen: 2154 times

Last Updated: Aug 26 '10 at 07:16 AM