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 lilithgow · Feb 01, 2011 at 06:55 PM · mousemousepositionmouseovertooltip

Setting ToolTip to Above Mouse Position

I'm putting a point and click game together, and I wanted my tooltip to show up over objects when the user points at them.

My tooltip recognizes objects just fine, saying the right names and appearing and all that, but I cannot get it to appear at mouse position.

Does anyone have any suggestions?

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

5 Replies

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

Answer by Justin Warner · Feb 01, 2011 at 07:38 PM

Get the position of the cursor, and use that + 100 on the Y or what not to get it above... Um,

var mousePos : Vector3 = Input.mousePosition;

And that'll get the X/Y and then you can just put the tool tip at the X/Y but add (I think UNity starts in the upper left corner, so it'd be subtract) 100, and it should work...

If that doesn't make sense, than ask!

Good luck!

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 lilithgow · Feb 02, 2011 at 03:06 PM 1
Share

That's great, all fixed now. I was using a GUIText, and so thought it would use a Vector2...doi.

I did have to convert that data into a ratio for the GUIText to interpret it, but that was just using the screen.width and screen.height which was nice and easy.

 transform.position = objectPlace;
avatar image
1

Answer by Mellemhund · May 25, 2011 at 06:56 PM

The Mouse seems to be inverted along the Y-axis - so to solve your problem try to do

Screen.height-mousePos.y

That put it right on the cursor for me!

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 Art Condelles · Feb 26, 2011 at 09:09 PM

Is there any possibility for the sake of someone who is not very well versed in scritping that you could maybe just go a touch deeper, I tried to implement this advice into my script and the position of the tooltip is at the bottom of the screen instead of by the cursor,this is the code I am using sorry if it seems remedial I am trying to learn on my own...

var mousePos: Vector3 = Input.mousePosition;

function OnGUI () { if (GUI.Button (Rect (10, 10, 100, 50), GUIContent("New Game", "Start a New Game"))) {

Application.LoadLevel (1);

 }
 GUI.Label (Rect (mousePos.x, mousePos.y - 100, 100, 20), GUI.tooltip);

}

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 Art Condelles · Feb 26, 2011 at 09:12 PM

Is there any possibility for the sake of someone who is not very well versed in scritping that you could maybe just go a touch deeper, I tried to implement this advice into my script and the position of the tooltip is at the bottom of the screen instead of by the cursor,this is the code I am using sorry if it seems remedial I am trying to learn on my own...

var mousePos: Vector3 = Input.mousePosition;</p> <p>function OnGUI () { if (GUI.Button (Rect (10, 10, 100, 50), GUIContent("New Game", "Start a New Game"))) {</p> <pre><code> Application.LoadLevel (1); } GUI.Label (Rect (mousePos.x, mousePos.y - 100, 100, 20), GUI.tooltip); </code></pre> <p>}

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 Art Condelles · Feb 26, 2011 at 09:13 PM

Sorry for double post I was trying to fix the code example

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

1 Person is following this question.

avatar image

Related Questions

Tooltip and mouse position 4 Answers

Tracking the mouse off-window 1 Answer

IPointerEnterHander only fires on click 0 Answers

Inconsistent Mouse Related Behavior in 2D 1 Answer

How to find out which object is under a specific pixel 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