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 AgentSasori · Aug 08, 2013 at 10:31 AM · guiflickeringmouseoverflicker

OnMouseOver GUI flickering if mouse moves Y

Hey Community.

I have a strange "flickering-problem" with GUI-elements. I've build a small c# script for collectable items. If the mouse hovers over an object a gui appears with some infos. It works so far, but if you move the mouse in Y the GUI is flickering. Did not find something to fix that in forum/answers...

Here's the code: using UnityEngine; using System.Collections;

 public class MakeItem : MonoBehaviour {
 
     // Definition
     public string name; // Name of that THING
     public string description; // Tell something about it
     public float weight = 1; // WTF is it so heavy? in kg
     public int slotType; // Where to put this shit (1=Backpack, 2=Toolbelt, 3=?)
     public int slotSize = 1; // Damn this takes a lot of place
     public int use = 1; // Can I use it? Throw it? Put it in my hand?
     public int stackSize = 1; // Stack it if you want, bro
     public float spawnrate; // Limit the spawnrate to INFINITE ;)    
     public int condition = 100; // good, weak? in percent
     public Texture2D icon;    
     
     private bool showItemInfos = false;
     
     void OnMouseOver() {
         showItemInfos = true;
     }
     
     void OnMouseExit() {
         showItemInfos = false;
     }
     
     void OnGUI() {
         if(showItemInfos) {
             int y;
             // get mouse position
             Vector3 mousePosition = Input.mousePosition;        
             
             // Draw some infos
             GUI.Box(new Rect(mousePosition.x,Screen.height- mousePosition.y, 100, 100), description);
             //print ("X: " + mousePosition.x + " Y: " + mousePosition.y);
             
             // show item infos
             GUI.BeginGroup(new Rect(Screen.width - 210, 10, 200, 200));
                 // draw a box as border
                 GUI.Box(new Rect(0, 0, 200, 200), name);
                 y = 20;
                 GUI.DrawTexture(new Rect(5, y, 50, 50), icon);
                 y += 50;
                 GUI.Label(new Rect(5, y, 200, 20), "Description: " + description);
                 y += 20;
                 GUI.Label(new Rect(5, y, 200, 20), "Weight: " + weight);
                 y += 20;
                 GUI.Label(new Rect(5, y, 200, 20), "Condition: " + weight);
             GUI.EndGroup();
             //print ("X: " + transform.position.x + " Y: " + transform.position.y);
             //GUI.Label(Rect(mousePosition.x, mousePosition.y), name);
         }
     }
 }
 
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

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Seizure · Aug 08, 2013 at 12:31 PM

Have you thought about doing this as tooltips instead?

Not quite sure how your inventory system is setup, is it all GUI elements that you display or are the inventory objects 3D? If your doing the inventory objects as GUI try this:

 GUI.Label (new Rect (0,0,25,25), new GUIContent ("Item Name" "ToolTip Info"), gameStyle.getStyle("customGUISkinTexture");
 
 GUI.Label (new Rect (Input.mousePosition.x,(Screen.height - Input.mousePosition.y) - 20, GUI.tooltip.Length * 12 ,30),GUI.tooltip, gameStyle.GetStyle("whitetext"));
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 AgentSasori · Aug 08, 2013 at 07:32 PM

All this are normal GUI elements. Why should I realize this with tooltips? Its working, just flickering. I guess thats not normal.

any other ideas?

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 Tactical_Beard · May 09, 2015 at 03:12 PM

An old question but i just ran into this and my fix was to off set the x and y.

GUI.Box(new Rect(mousePosition.x + 2,Screen.height- mousePosition.y + 2, 100, 100), description);

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

16 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

Related Questions

Display Press E to Pickup when mouse over object 2 Answers

Z-fighting problem. 1 Answer

Polygon flicker glitch on specific mobile devices 0 Answers

Mouseover using GUI.Tooltip 0 Answers

Mesh render flicker 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