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
8
Question by bjarnefisker · Dec 07, 2010 at 06:43 PM · editorinspectormouseovertooltipinformation

Additional information on mouseover in the inspector

Hey,

Some standard Unity scripts shows additional information when you mouseover the variable in the inspector. Does anyone know if there is a standard way of displaying this information on custom variables? (Both using public variables and/or Editor script)

See attached image on what i am trying to replicate.

Unity information box

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

4 Replies

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

Answer by Bryan-Legend · Nov 20, 2014 at 07:35 PM

As of Unity 4.5 or later just do this. The tooltip attribute is now built in.

 public class SomeClass : MonoBehaviour
 {
     [Tooltip("This is a great tooltip")]
     public int someVariable = 5;
 }
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
12

Answer by trololo · Aug 09, 2013 at 10:26 AM

 GUIContent content = new GUIContent("Text", "Info Pop-up");
 int test = EditorGUILayout.IntField(content, test, GUILayout.Width(100f));
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 Oncle-Ben · Aug 17, 2015 at 09:18 PM 0
Share

The tooltip attribute method works great for static tips, but this is the way to go if your tooltip need to change dynamically. Thanks trololo.

avatar image
5

Answer by Lev-Lukomskyi · Apr 12, 2014 at 09:49 PM

You can add tooltips easily with new Unity PropertyDrawers feature:

Assets/Scripts/TooltipAttribute.cs:

 using UnityEngine;
 
 public class TooltipAttribute : PropertyAttribute
 {
     public readonly string text;
 
     public TooltipAttribute(string text)
     {
         this.text = text;
     }
 }

Assets/Editor/TooltipDrawer.cs:

 using UnityEditor;
 using UnityEngine;
 
 [CustomPropertyDrawer(typeof(TooltipAttribute))]
 public class TooltipDrawer : PropertyDrawer
 {
     public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
     {
         var atr = (TooltipAttribute) attribute;
         var content = new GUIContent(label.text, atr.text);
         EditorGUI.PropertyField(position, prop, content);
     }
 }

And use:

 public class SomeClass : MonoBehaviour
 {
     [Tooltip("This is a great tooltip")]
     public int someVariable = 5;
 }
Comment
Add comment · Show 3 · 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 draxus99 · May 11, 2014 at 09:32 PM 0
Share

this solution worked flawlessly, thanks Lev

avatar image pengo · Jun 04, 2014 at 06:21 AM 2
Share

For anyone stumbling upon this solution who has Unity 4.5 or later, you can now use the [Tooltip("This is my tooltip")] attribute without using any of the plugin/setup code (i.e. you don't TooltipAttribute.cs nor TooltipDrawer.cs any more)

avatar image GrayedFox · Aug 26, 2014 at 02:20 PM 0
Share

thanks for this -- working perfectly on Unity Pro 4.3. slight problem, this requires using Unity Engine which works fine during runtime in the editor. however building for iOS throws a compiler error (as expected) -- thus I end up wrapping all my tool tips in pre compiler tags #if UNITY_EDITOR [ToolTip("some tooltip")] #endif

this is a nooby question .. but what's the full method call for [Tooltip("some tooltip")] ? UnityEngine.Tools.[Tooltip("some tool tip")] doesn't work, neither does [UnityEngine.Tools.Tooltip("some tool tip")] (neither does UnityEngine.PropertyDrawer... etc

avatar image
2

Answer by skovacs1 · Dec 07, 2010 at 07:35 PM

For that you would need to define a custom editor with a EditorGUILayout.PropertyField which is passed a GUIContent with the appropriate tooltip set.

Comment
Add comment · Show 2 · 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 bjarnefisker · Dec 07, 2010 at 07:50 PM 0
Share

Great! I somehow missed the GUIContent variable and only used the overloaded method that takes a String label ins$$anonymous$$d. To bad that it don't work (out-of-the-box) on some EditorGuiLayout functions like Vector3Field but that's not a big problem. Thanks!

avatar image anomalous_underdog · Mar 24, 2011 at 10:26 AM 0
Share

Any chance you could give us some sample code template?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Retrieve Variable's [Tooltip()] Property From a Custom Inspector (C#) 2 Answers

Draw specific Object Inspector into Rect 1 Answer

How can a class inherit from another that is modified by editor 1 Answer

How should I serialize data that is also editable in the Inspector? 2 Answers

Customizing Inspector variables. 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