Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Changing Alpha values upon OnMouseOver?

$
0
0
Hi there! I have recently started using Unity and evidently, I am a beginner at this stuff. So here is my story. I have created a Gui Texture and assigned an image to it. What I wanted to do is keep the Texture transparent until the mouse cursor hovers over it; and go back to being transparent when the mouse cursor leaves the Texture - pretty straight forward. So I assigned this javascript to my texture: function OnMouseOver () { guiTexture.color.a = guiTexture.color.a + 1 * Time.deltaTime; Debug.Log("Mouse is over"); } function OnMouseExit () { guiTexture.color.a = guiTexture.color.a - 1 * Time.deltaTime; Debug.Log("Mouse is on exit"); } The problem is, the first part works fine, the part where the texture comes out of its transparent state when the cursor hovers over it. However, when the cursor leaves the texture, the Texture doesn't go back to being transparent, its alpha values don't even bother going down again. What am I doing wrong? Any help would be much appreciated. Ps. I'm using Unity Pro.

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>