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 Jezebel · Sep 07, 2010 at 04:24 AM · labelmouseover

OnMouseOver GUI not appearing

objRect.y = Mathf.Abs(MousePos.y - Camera.main.pixelHeight);

Is there a Java equivalent to C#'s Mathf.Abs?

Thank you.

EDIT: This is my complete script, I have another problem!

var ShowRollover; var objRect : Rect; var mousePos : Vector2; var offset : Vector3;

offset = new Vector3(16, 16, 0);

function Update() { ShowRollover = false; objRect = new Rect(0, 0, 500, 100); mousePos = new Vector2(0, 0); }

function OnMouseOver() { ShowRollover = true; }

function OnMouseExit() { ShowRollover = false; }

function OnGUI() { if (ShowRollover) { mousePos = Input.mousePosition + offset; objRect.x = mousePos.x;

     GUI.contentColor = Color.yellow;

     objRect.y = Mathf.Abs(mousePos.y - Camera.main.pixelHeight);    
     GUI.Label(objRect, "Name: Common Carp\nNumber of fish in patch: 8");
 }

}

I found that if the label cannot be seen even when I'm hovering the mouse over the object with the collider. Is there any mistake that I made?

Comment
Add comment · Show 2
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 · Sep 07, 2010 at 04:32 AM 0
Share

$$anonymous$$athf.Abs should work in UnityScript.. are you getting an error when you try? If so, can you post it?

avatar image · Feb 08, 2011 at 06:40 AM 0
Share

Don't set ShowRollover to false in Update(), and change On$$anonymous$$ouseOver() to On$$anonymous$$ouseEnter().

1 Reply

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

Answer by Eric5h5 · Sep 07, 2010 at 04:37 AM

Mathf.Abs isn't C#, it's a Unity-specific function (Mathf is a Unity-specific class). System.Math.Abs isn't C# either, it's Mono/.NET. In fact there are no functions that are C#-only. The code you wrote is valid JS. (However Java is not a valid "nickname" for Javascript, as it's a different language entirely, and not used in Unity.)

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

Getting Rect from scrollview according to position in scrollview 2 Answers

Window pops up when mouse is over a GUI.Label 1 Answer

how to delete GUI.Label from script? 1 Answer

GUI.Label() does not show up on WebPlayer 2 Answers

Trouble Positioning a GUILayout.Label, or as a button? 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