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
2
Question by A-Rich · May 21, 2010 at 04:23 PM · textpopupmouseover

Text box pop up on mouseover

Hi all, I've been searching the forums and answers for quite a while and haven't found quite what I'm trying to do. I'm trying to find a way to have a text box pop up with descriptive text when certain objects are moused over in the scene. For example, there will be a number of books scattered about and when the player puts the cursor on the book, the title of the book will be displayed in the pop up box. This artist who's a terrible coder would greatly appreciate the help. Thanks!

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

1 Reply

· Add your reply
  • Sort: 
avatar image
6

Answer by equalsequals · May 21, 2010 at 05:16 PM

In order for an object in 3D space to receive mouse events it needs a Collider component applied and active.

Once your object has a Collider, you must attach a Behaviour script which handles the event OnMouseOver (or OnMouseEnter, theres a bunch see which one is right for you in the docs).

The next step would be creating your popup box. There are a couple ways of doing this, depending on how you want to handle it, your can use Unity's immediate mode OnGUI() to draw it with a script similar to this:

private bool _mouseOver = false;
void OnGUI()
{
    if(!_mouseOver) return;
    //draw your GUI stuff here with Unity's OnGUI code - see ref for details
}
void OnMouseOver()
{
    _mouseOver = true;
}
void OnMouseExit()
{
    _mouseOver = false;
}

Another way to do it with just a GUITexture would be to use the OnMouseOver/OnMouseExit functions to show/hide a referenced GUITexture.

Hope that helps.

==

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 A-Rich · May 21, 2010 at 11:45 PM 0
Share

Thank you for the help! I just may be able to get this to work.

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

1 Person is following this question.

avatar image

Related Questions

Text pop up when mouse over gui button 2 Answers

I am making a MouseOver function and its not working 0 Answers

How to make text pop up for a few seconds? 3 Answers

How to make text appear only when over button(highlighted) 2 Answers

Play animation only once? 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