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 PaolaFalcon · Aug 12, 2013 at 09:37 PM · guibuttontooltip

Why is a tooltip ignoring a Rect and not another?

Hi, I didn't figure out how to write a good title, sorry.

I'm trying to make a grid of buttons to appear as an inventory. I'm totally new at Unity, please excuse my ignorance..

I'm rendering the inventory on the OnGUI event, I specify the position and size of the inventory area, and then I specify a portion of it to an area called tooltipArea. I want to hover a button and a tooltip that appears on the bottom part of the inventory (in the tooltipArea), with some characteristics of the item hovered.

What I did is that I assigned the tooltip to a button succesfully, but this tooltip won't appear if it's outside of the button area.

This is a screenshot of what I have:

Inventory

And this is my code:

 void OnGUI(){
         GUI.skin = inventorySkin;        
         if(isMenuOpen){
 //These boxes are for seeing what space are this areas actually occupying
             GUI.Box(new Rect(inventoryAreaNormalized.x - inventoryBackPadding, inventoryAreaNormalized.y - inventoryBackPadding, inventoryAreaNormalized.width + inventoryBackPadding*2, inventoryAreaNormalized.height + inventoryBackPadding),"");
             GUI.Box(new Rect(tooltipArea),"");
             GUI.BeginGroup(inventoryAreaNormalized);            
             int count = 0;

 //My intent of grid...
         
             for(int renglon = 0; renglon < nrenglones; renglon++){
                 var top = renglon * baseItemArea.height;
                 for(int columna = 0; columna < colSize ; columna++){
                     var left = columna * baseItemArea.width;
                     var thisRect = new Rect(left, top, baseItemArea.width, baseItemArea.height);    
                     
                     if(Inventory.ItemBag.Count > count){                        
                         if(GUI.Button(new Rect(thisRect), new GUIContent(Inventory.ItemBag[count].Quantity.ToString(), Inventory.ItemBag[count].Icon, Inventory.ItemBag[count].Name))){                            
                             //Some actions
                         }

                         //THIS DOES NOT WORK
                         if (!string.IsNullOrEmpty(GUI.tooltip))   
                             GUI.Box (new Rect(tooltipArea), GUI.tooltip);
                         
                         count++;
                     }else if(renglon * colSize + columna + 1 <= Inventory.Capacity){ 
                         if(GUI.Button(new Rect(thisRect), "")){    }                                            
                     }else{  items
                         GUI.Box(new Rect(thisRect),"");
                     }
                 }                
             }        
         GUI.EndGroup();
         }
     }

Ok, so please, any guidance is very welcome, I'm just playing around and I can't figure this out, I searched in the questions in this forum and I didn't got this particular question.

Again, to clarify, this line:

 GUI.Box (new Rect(tooltipArea), GUI.tooltip);

only works like this

 GUI.Box (new Rect(thisRect), GUI.tooltip);

placing the tooltip over the button (an undesired effect).


Edit:

So I changed

 GUI.Box (
     new Rect(thisRect.x+15,
             thisRect.y+15,
             thisRect.width,
             thisRect.height), GUI.tooltip);


just to see if it had something to do with the button area, but no. This is the result:

Edit

Why is the tooltip ignoring the tooltipArea? What am I missing?

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
0
Best Answer

Answer by PaolaFalcon · Aug 12, 2013 at 10:20 PM

Can't believe my ignorance and inexperience.

Never ocurred to me that this bit was the thing I was not aware of. Sorry all.

 GUI.BeginGroup(inventoryAreaNormalized);    

Everything inside it is a 'child' of it, and I forgot.

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

15 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

Related Questions

How to add intermediate tooltip to GUI button? 1 Answer

Tooltip does not show 1 Answer

Generating tooltips for multiple buttons. 1 Answer

How to assign a different tooltip to each GUI button? 0 Answers

Why can't I get my tooltip to show only when there is a tooltip set? 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