x


OnMouseOver Problem

I have problem with OnMouseOver function. I want the GUI 3D Text to change its color from white to red on mouse hover,but when I run application nothing happens. Here's the code:

function OnMouseOver () {
renderer.material.color=Color.red;
}

The code is attached to 3D Text.

And also Box Collider is added.

How do I fix this problem?

more ▼

asked Jul 17 '11 at 05:29 PM

srafciger gravatar image

srafciger
21 17 19 21

ha! I just finished writing an answer suggesting the collider too! If you have added the collider then I don't see anything wrong with the script. Works fine for me.

Jul 17 '11 at 06:45 PM kaleetos

I don't see any problem too, so I'm confused especialy because this is just a basic function.BTW...Sorry :D

Jul 17 '11 at 06:50 PM srafciger

Same here, works fine for me. I suggest, if you haven't already, creating a new scene with a 3DText, adding a new box collider then attaching the script. Let us know the results.

Jul 17 '11 at 06:50 PM AdamOwen

Yeah, I tried it again with default Arial font and it http://work.It seems that there is problem with font I was using before. How could I fix it so that imported font works?

Jul 17 '11 at 06:54 PM srafciger

Hmm, the 3DText isn't on the IgnoreRaycast layer is it? OnMouseOver returns on colliders so the text itself shouldn't have anything to do with it.

Jul 17 '11 at 07:06 PM AdamOwen
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

@Aldwoni

It is.I created new font material with my fonts font Texture but now I have problem changing that new font materials color.

Neither

renderer.material.SetColor("_Color",MyColor);

or:

renderer.material.SetColor("_TextColor", MyColor);

works.

more ▼

answered Jul 18 '11 at 05:22 PM

srafciger gravatar image

srafciger
21 17 19 21

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

x49

asked: Jul 17 '11 at 05:29 PM

Seen: 1071 times

Last Updated: Jul 18 '11 at 05:22 PM