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
0
Question by _Petroz · Dec 16, 2010 at 11:08 PM · onmouseenteronmouseexit

OnMouseExit fires every frame when the mouse is down?

I have a model with a rigidbody attached and I change the material in OnMouseEnter and OnMouseExit. It works correctly when I don't hold the mouse button down, but when I do have any mouse button held down and I drag over the object it flickers. Is this a known bug or am I doing something wrong?

Edit: added code

void OnMouseEnter() { if (sCurrentHoverSlot == null) { sCurrentHoverSlot = this; gameObject.renderer.material = GUIManager.instance().weaponSlotHoverMaterial; } }

void OnMouseExit() { if (sCurrentHoverSlot == this) { sCurrentHoverSlot = null; gameObject.renderer.material = GUIManager.instance().weaponSlotDefaultMaterial; } }

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

2 Replies

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

Answer by Eric5h5 · Dec 17, 2010 at 02:34 AM

It's a bug that happens if you're using OnGUI.

As a side note, you don't need a rigidbody if you're just using OnMouseEnter/Exit, all you need is a collider. If you are using it as a moving object under physics control, never mind.

Comment
Add comment · Show 4 · 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 _Petroz · Dec 17, 2010 at 03:55 AM 0
Share

Thanks, if it's a known bug I can just live with it for now. I'm not using the rigidbody for anything except the mouse collisions. If i remove the rigid body On$$anonymous$$ouseEnter and On$$anonymous$$ouseExit no longer get fired.

avatar image Eric5h5 · Dec 17, 2010 at 05:09 AM 0
Share

Rigidbodies are only necessary for objects in motion under physics control. On$$anonymous$$ouseEnter and On$$anonymous$$ouseExit depend only on a collider present, not a rigidbody. They do fire without a rigidbody.

avatar image _Petroz · Dec 18, 2010 at 11:25 AM 0
Share

That isn't the behaviour I'm seeing. I have appended the code to my post. Here is a demonstration: http://www.youtube.com/watch?v=Fj$$anonymous$$8fqAmVdo

avatar image Eric5h5 · Dec 18, 2010 at 04:04 PM 0
Share

@Petroz: Aha, the problem is that you're using a compound collider. This isn't a bug. By design, compound colliders act as a single collider when you add a rigidbody to the parent, and therefore only the root object will react to On$$anonymous$$ouseEnter. If you add a rigidbody to the child, you break the compound collider; as the docs say, you should not parent rigidbodies together. So the rigidbodies have nothing to do with On$$anonymous$$ouseEnter, but are rather changing how the colliders themselves work in the case of parent/child.

avatar image
0

Answer by uhahaha · Dec 17, 2010 at 01:52 AM

Do you have something inside any of the OnMouseDown/Over/Drag functions?

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

No one has followed this question yet.

Related Questions

Can't seem to get OnMouseExit and Destroy(GameObject) to work properly 1 Answer

OnMouseEnter/Exit not working when pressing button to advance scene 2 Answers

Instantiate object OnMouseOver, then delete the instantiated object OnMouseExit. 1 Answer

OnMouseDown 2 Answers

Change cursor on OnTrigger 0 Answers


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