Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by teseer_zaeem · Nov 28, 2017 at 06:49 PM · mouse click

Detect mouse over without rigidbody... Using Raycast maybe?

I've a GameObejct which looks like a cube... attached to it many other smaller gameobjects on it's surface...I want to show the name of any of those smaller gameobjects whenever I hover the mouse over them... Any suggestions ? :)

P.S: I can't use Colliders because the cube collider is bigger than any of the smaller gameobjects colliders... so they are contained in it... that's why it won't detect any mouse over using a collider and a rigidbody.

Comment
Add comment · Show 3
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 MaxGuernseyIII · Nov 28, 2017 at 07:31 PM 0
Share

Why not create a script that specifically monitors On$$anonymous$$ouseEnter (and maybe On$$anonymous$$ouseLeave, as your needs dictate)?

I posted a similar solution for detecting clicks a while back.

Basically, you make a script that is only about detecting the mouse events you want and publishing them as events, then you trap the events and handle them as needed.

In your case, you might even write a specific script that traps On$$anonymous$$ouseEnter, publishes the name of the current cube to some well-known location, then traps On$$anonymous$$ouseLeave and clears the name.

avatar image teseer_zaeem MaxGuernseyIII · Nov 28, 2017 at 07:51 PM 0
Share

Sir the problem is I can't detect whether the mouse entered or not.

avatar image MaxGuernseyIII teseer_zaeem · Nov 28, 2017 at 08:06 PM 0
Share

Yeah. I see that it's because you have a larger collider that can block the signal.

There might be something here: https://docs.unity3d.com/$$anonymous$$anual/LayerBasedCollision.html

...but I'm guessing that this is a better bet: https://answers.unity.com/questions/392601/onmouseenter-through-colliders.html

2 Replies

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

Answer by Darkforge317 · Nov 28, 2017 at 07:10 PM

I would still keep colliders on the smaller objects. Just use Physics.RaycastAll



It will collect all objects that the Ray passes through, then you can simply display the name of the last object it hits.
That way it'll hit the big cube, store it in the array, and then hit one of the objects inside of it, and store that in the array as well. Just look at the last object in the array and display its name.

Comment
Add comment · Show 3 · 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 teseer_zaeem · Nov 28, 2017 at 07:22 PM 0
Share

Trying it... Thanks ☺

avatar image Darkforge317 teseer_zaeem · Nov 28, 2017 at 07:43 PM 0
Share

Let me know if it works! :)

avatar image teseer_zaeem · Nov 29, 2017 at 08:28 PM 1
Share

Your answer helped me achieve my desired result ^_^ Thanks a lot ♥

avatar image
0

Answer by $$anonymous$$ · Nov 28, 2017 at 07:03 PM

Can you share a print of your screen? Will help find a solution.

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 teseer_zaeem · Nov 28, 2017 at 07:20 PM 0
Share

Here you go :)

1.png (397.8 kB)

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

73 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Destroy Objects to Load New Scene 3 Answers

How to detect mouse click on sprite? 2 Answers

Click on Arrows to Move Object. 1 Answer

Display material options menu on click 0 Answers

Select something using mouseclick 2 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