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
14
Question by ProjectCryken · Apr 24, 2013 at 04:50 PM · inspectorcomments

Having Text Or Notes In The Inspector?

Is there a way(like I see in many plug-ins) to have text or notes in the inspector amongst all the variables? For example I have a couple of lines of text above of variable to remind people what options they have for this variable?

Thanks In Advance!

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 alexanderbrevig · Apr 24, 2013 at 05:01 PM 0
Share

I don't know about a way to do this, but it's been a wish of $$anonymous$$e for some time: http://feedback.unity3d.com/unity/all-categories/1/hot/active/show-comments-for-variables-in-t

avatar image ProjectCryken · Apr 24, 2013 at 05:22 PM 0
Share

Huh, I assume its something that can be done.

6 Replies

· Add your reply
  • Sort: 
avatar image
65

Answer by MasterChiefLegend · Apr 07, 2015 at 12:31 AM

I think you just mean the built in Attributes Unity have already set up?

See

http://docs.unity3d.com/ScriptReference/TooltipAttribute.html

and

http://docs.unity3d.com/ScriptReference/HeaderAttribute.html

Example code snippet:

 [Header("Button Settings")]
 [Tooltip("Arbitary text message")]
 public string OnClickText = "";
 [Tooltip("Useful GameObject you might need.  Note there is a Sender property that is this class.")]
 public GameObject Object;
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
10

Answer by ShawnFeatherly · Sep 30, 2016 at 08:49 PM

For a general note on the component, create a new variable that has a [TextArea] Attribute.

 [TextArea]
 [Tooltip("Doesn't do anything. Just comments shown in inspector")]
 public string Notes = "This component shouldn't be removed, it does important stuff.";
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
6

Answer by usergame · Mar 27, 2017 at 09:54 AM

I realize this question is a few years old but I was recently looking to do the same and didn't like the dummy variable suggestion, so I wrote my own really simple PropertyDrawer and HelpAttribute. More information at the forum post:

https://forum.unity3d.com/threads/helpattribute-allows-you-to-use-helpbox-in-the-unity-inspector-window.462768/

Hope this helps someone out who is still looking for a more elegant solution.

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 Murddock · Jul 19, 2018 at 10:16 PM 0
Share

You are awesome !!! Tnx a lot!!!

avatar image
3

Answer by AlanMattano · Dec 12, 2015 at 04:27 PM

After adding attributes to your script as MasterChiefLegend mention, you can create text notes in the inspector following these steps:

  • http://forum.unity3d.com/threads/add-info-text-notes-into-the-inspector.265330/

Here it is the GitHub link:

  • https://github.com/ALanMAttano/UnityInspectorInfoTextNote

Allowed to place info in the inspector in a simple way: alt text


inspectornote.png (31.1 kB)
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
2

Answer by Loius · Apr 24, 2013 at 05:28 PM

[CustomEditor(typeof(YourType))] is what you're looking for.

http://docs.unity3d.com/Documentation/ScriptReference/Editor.html

 GUILayout.Label("Remember that one thing about this variable!");
 x = EditorGUILayout.IntField(whatever);
Comment
Add comment · Show 5 · 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 ProjectCryken · Apr 24, 2013 at 05:56 PM 1
Share

That scripting reference page appears to be extremely overkill for what I want. Is this the only way to achieve this?

avatar image Loius · Apr 24, 2013 at 06:29 PM 0
Share

I was gonna say yes and go off on a tangent about auto-creating editors, but then i found this which is new in Unity 4 and might be just what you're looking for;

http://blogs.unity3d.com/2012/09/07/property-drawers-in-unity-4/

avatar image ProjectCryken · Apr 24, 2013 at 06:53 PM 0
Share

Hmmm, the reason I want this 'comment' above my variables is just to save time and for convenience. If all of that is required it would have the opposite effect :(

avatar image Loius · Apr 24, 2013 at 11:03 PM 0
Share

This lets you add comments to a dummy variable, then you just put the dummy in the list of your real properties. I've only played with drawers today, but it's not immediately apparent to me how to go about drawing the actual property (i.e. how to draw the actual int field without a huge if-else block).

 #if UNITY_EDITOR
 using UnityEngine;
 using UnityEditor;
 using System.Collections;
 
 public class CommentAttribute : PropertyAttribute {
     public readonly string tooltip;
     public readonly string comment;
     
     public CommentAttribute( string comment, string tooltip ) {
         this.tooltip = tooltip;
         this.comment = comment;
     }
 }
 
 [CustomPropertyDrawer(typeof(CommentAttribute))]
 public class CommentDrawer : PropertyDrawer {
     const int textHeight = 20;
     
     CommentAttribute commentAttribute { get { return (CommentAttribute)attribute; } }
     
     public override float GetPropertyHeight(SerializedProperty prop, GUIContent label) {
         return textHeight;
     }
     
     public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label) {
         EditorGUI.LabelField(position,new GUIContent(commentAttribute.comment,commentAttribute.tooltip));
     }
 }
 
 public class PropDraw : $$anonymous$$onoBehaviour {
     [Comment("This is the description","And this is the tooltip")]
     public int thisIsADummy;
 }
 
 #endif
avatar image IvanLazarov · Mar 25, 2014 at 09:38 AM 0
Share

Thanks Loius, that's a very neat solution.

  • 1
  • 2
  • ›

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

22 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

Related Questions

How to indent EditorGUILayout.BeginToggleGroup() 1 Answer

C# public - dropdown selection? 3 Answers

Inspector cannot find script instance 1 Answer

Inspector: Animator: Animations drop down not appearing? 1 Answer

c# enum wont show in inspector 3 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