x


Changing Texture's Color

Hello~

I'm trying to change Texture's color.

I can do it by Creating a GUI Texture and setting color wanted to the Texture in Inspector window.

Problem is, I have some GUI buttons created in JavaScript. I could use two Textures (one for normal, one for active) to make the button change when I click on it. But now, I want to use only one Texture to achieve this. So I think the best way is change the color of the Texture when I click on it. Some people said that we could implement this by using GUISkin or GUIStyle, I think the second method is using two different Textures,,

So.. Can any one please tell me how I can work this out?.

Thanks! ^.^

more ▼

asked Apr 18 '10 at 10:35 PM

Jin gravatar image

Jin
67 10 13 21

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

1 answer: sort voted first

If it's "GUI Texture" as in GUITexture, then do guiTexture.color = whatever. If you mean a texture as drawn in OnGUI, then change GUI.contentColor.

more ▼

answered Apr 18 '10 at 10:40 PM

Eric5h5 gravatar image

Eric5h5
80.1k 41 132 519

Thanks! I meant a texture as drawn in OnGUI,,It's exactly what I'm looking for , But Unfortunately I still have no idea with how to use GUI.color to implement button's color changing when I clicked on.. I use "GUIStyle.normal.background = texture1; GUIStyle.active.background = texture2; GUI.Button(Rect (blah) ,"", GUIStyle)" .. I think the method using GUI.color doesn't make sence in this way.. What do you think, Eric?

Apr 19 '10 at 12:42 AM Jin

@Jin, set a boolean if the button is clicked and use the boolean to change the color or not.

Apr 19 '10 at 01:22 AM Eric5h5

Thanks Eric~ Thank you very much!

Apr 19 '10 at 01:54 AM Jin
(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:

x3677
x2192
x506

asked: Apr 18 '10 at 10:35 PM

Seen: 5671 times

Last Updated: Apr 18 '10 at 10:35 PM