Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
5
Question by Jean-Fabre · Oct 20, 2010 at 08:28 AM · guifunctioncallmouseoveronmouseover

How to detect Mouse over gui and guilayout elements?

Hi,

Say I have a gui slider controlling a model property and when the user mouse over this slider I want to hilite the 3d model that will be affected by this slider.

Problem is I can't find a way to register a function to gui mouse events. I do not need to modify the style or skin of the gui on mouseover, I need to call a function of mine.

Is it possible? or am I missing the plain obvious?

thanks for your help

Jean

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

4 Replies

· Add your reply
  • Sort: 
avatar image
4
Best Answer

Answer by Jean-Fabre · Oct 21, 2010 at 11:00 AM

Found the answer here:

http://unity3d.com/support/documentation/ScriptReference/GUILayoutUtility.GetLastRect.html

There is also a clear example on detecting mouseover. Works perfectly.


Here's a solution that works for GUILayout also ... what a hassle.

Just after GUILayout.HorizontalSlider ...

 if (Event.current.type == EventType.Repaint &&
     GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
     {
     usingSlider=true;
     }

then in your update routine ....

 void Update()
     {
     if ( Input.touchCount == 0 ) usingSlider = false;
     if ( usingSlider == true ) return;
     .. continue as normal...

that's it !

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fattie · Nov 15, 2014 at 09:23 AM 0
Share

$$anonymous$$ - brilliant, but doesn't seem to work for GUILayout ... :/

... later: I added an approach that works perfectly for GUILayout.

avatar image
1

Answer by PeterDC · Oct 20, 2010 at 01:01 PM

Check out the answer to this question: Mouseover-Detection.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jean-Fabre · Oct 20, 2010 at 01:20 PM 0
Share

ok, thanks for the reference, I hoped for a proper built in way, cause rect detection is not very nice really...and hittest doesn't work just yet, currently investigating why, but it returns always a guielement with nothing in it hwereever aclick, likely to become my next question.

avatar image
1

Answer by morbidcamel · Oct 17, 2014 at 06:32 AM

Anybody knows how to do this in the 4.6 UI ? I don't want my controls to fire if I'm hovering over my hud elements with the mouse.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by DrDecipher · Aug 15, 2014 at 04:37 AM

Check out the second post here: http://forum.unity3d.com/threads/gui-button-hover-change-text-color-solved.262440/#post-1735230

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

OnMouseOver not working.. ? 2 Answers

StartCoroutine important for using yield? 1 Answer

Call a Function from another Script 1 Answer

OnMouseOver Tower Gui Health Bar 2 Answers

On Mouse Over Problem 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges