Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Rickenbaker · Feb 23, 2017 at 09:45 PM · c#guilayouttooltipguilayout.button

Displaying multiple GUILayout button tooltips in a single GUILayout box?

Hello all,

So I just discovered how to display information when the mouse hovers above a GUILayout button in a custom inspector (Oh, big deal, right?). Lets say I have 4 GUILayout buttons in a row, and I would like to display their tolltips in a single GUI layout box, which is positioned below those buttons, when I hover the mouse over them one by one. Anyone have any suggestions on how this could be accomplished?

So far I am displaying the tooltip by using this:

 EditorGUILayout.BeginHorizontal();
  if (GUILayout.Button(new GUIContent("Place object A", "Place selected object in a scene."), GUILayout.Height(30)))
      {
             //Place the object A code;
      }
  
   if (GUILayout.Button(new GUIContent("Remove object A", "Remove selected object"), GUILayout.Height(30)))
                          {
                              //Remove object A code;
                          }
  GUILayout.EndHorizontal();

Any input will be appreciated, thanks in advance!

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

Answer by Nat3 · May 19, 2020 at 11:07 AM

Thanks for the tooltip code! It helped me. :-)

I know this post is old, but for the common label to show tooltip, if you mean Game view, I found an example. https://docs.unity3d.com/ScriptReference/GUI-tooltip.html

If you are looking for the one for Inspector GUI, how about this? (I couldn't find a better way...)

MyPlayer.cs (Attach this to GameObject)

 using UnityEngine;
 
 public class MyPlayer : MonoBehaviour
 {
 
 }

MyPlayerEditor.cs

 using UnityEditor;
 using UnityEngine;
 
 [CustomEditor(typeof(MyPlayer))]
 [CanEditMultipleObjects]
 public class MyPlayerEditor : Editor
 {
     void OnEnable()
     {
     }
 
     public override void OnInspectorGUI()
     {
         GUIContent btnA = new GUIContent("A");
         GUIContent btnB = new GUIContent("B");
         GUIStyle btnstyle = new GUIStyle(GUI.skin.button);
         btnstyle.margin = new RectOffset(10, 10, 10, 10); // left, right, top, bottom
         Rect btnARect = new Rect(btnstyle.margin.left, btnstyle.margin.top, 100, 30);
         Rect btnBRect = new Rect(btnstyle.margin.left + btnARect.width + btnstyle.margin.right, btnstyle.margin.top, 100, 30);
         GUILayout.BeginHorizontal();
         if (GUILayout.Button(btnA, btnstyle, GUILayout.Width(btnARect.width), GUILayout.Height(btnARect.height)))
         {
             //Place the Button A code;
         }
         if (GUILayout.Button(btnB, btnstyle, GUILayout.Width(btnBRect.width), GUILayout.Height(btnBRect.height)))
         {
             //Place the Button B code;
         }
         GUILayout.EndHorizontal();
         if (Event.current.mousePosition.x > btnARect.x && Event.current.mousePosition.x < btnARect.width &&
             Event.current.mousePosition.y > btnARect.y && Event.current.mousePosition.y < btnARect.height)
         {
             EditorGUILayout.LabelField("A tool tip");
         }
         else if (Event.current.mousePosition.x > btnBRect.x && Event.current.mousePosition.x < (btnBRect.x + btnBRect.width) &&
             Event.current.mousePosition.y > btnBRect.y && Event.current.mousePosition.y < btnBRect.height)
         {
             EditorGUILayout.LabelField("B tool tip");
         }
         else
         {
             EditorGUILayout.LabelField("");
         }
     }
 }
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

314 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Set vertical text GUI layout 0 Answers

Loading a different texture on multiple GUILayout buttons in custom editor inspector 0 Answers

Stop tooltip disappearing off screen 1 Answer

Collsions during animations 0 Answers

Plane.RayCast not hitting at all 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