x


Changing a GUI texture while hovering over an object?

I have a cube, and I want the cursor (which is a GUI texture situated at the center of the screen) to change textures as it hovers over it. The GUI texture is not parented to the cube, because there are going to be multiple cubes.

more ▼

asked Apr 21 '11 at 06:06 AM

Irsan gravatar image

Irsan
65 39 42 50

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

2 answers: sort voted first

http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnMouseOver.html http://unity3d.com/support/documentation/ScriptReference/Material-mainTexture.html

more ▼

answered Apr 21 '11 at 07:55 AM

robertmathew gravatar image

robertmathew
571 35 39 51

(comments are locked)
10|3000 characters needed characters left
var male : Texture2D; 
var ren : Renderer;  //IS THE CUBE WHERE YOU WANT CHANGE THE TEXTURE 


    function OnGUI()
         {



 ren.renderer.material.mainTexture = male;


          }
more ▼

answered Apr 21 '11 at 08:00 AM

robertmathew gravatar image

robertmathew
571 35 39 51

USE MOUSE OVER FUNCTION

Apr 21 '11 at 08:04 AM robertmathew

I have no idea what this is.

Apr 21 '11 at 08:14 AM Irsan
(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:

x3688
x2199
x379
x198
x55

asked: Apr 21 '11 at 06:06 AM

Seen: 1634 times

Last Updated: Apr 21 '11 at 06:06 AM