x


Texture2d Change Texture by MouseClick

Hey,

I want to create my own buttons, but it doesn't work.

I have 2 pictures which are nearly the same, exept the "darkness".

So I made a GUITexture and I dragged the first one(the lighter one) on it, that works

Then I added a JsScript.

Here's my question... How can I change the Material of the GUITexture by script when the GUITexture gets clicked

Something like:

function OnMouseDown () { //change the Material of the GUITexture to the darker image //load the next level/load the next scene }

function OnMouseExit () { // change it back to the brighter one/the normal one, I added first }

If GUITexture are the wrong choice for that, please give me another soution

more ▼

asked Nov 19 '10 at 07:46 PM

DrDorian gravatar image

DrDorian
1 1 1 1

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

1 answer: sort newest

You have mixed some things a bit:

these you can use to give even more effects, for example highlight the button.

function OnMouseEnter () // when you hover your mouse over the button.

function OnMouseExit () // when your mouse leaves your button area.

This is what you want to use:

function OnMouseDown () // when you click down your mouse button.

(this is where you want to have your texture change)

function OnMouseUp () // when you lift up your mouse button.

(this is where you want to load new scene, if earlyer, then your effect loses its point)

more ▼

answered Nov 19 '10 at 08:52 PM

longisle gravatar image

longisle
42 4

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

x494
x389
x15

asked: Nov 19 '10 at 07:46 PM

Seen: 1247 times

Last Updated: Nov 19 '10 at 07:46 PM