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!

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

Huh, I assume its something that can be done.

7 Answers

7

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

See

and

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;

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.";

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.

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

FAST

  1. Make a C# script: CommentInformationNote
  2. Copy and past this code
using UnityEngine;

[AddComponentMenu("Miscellaneous/README Info Note")]
public class CommentInformationNote : MonoBehaviour
{
    [TextArea(10,1000)]
    public string Comment = "Information Here.";
}

*. Place the script into the game object
*. Notice that you can use Add Component in the Inspector.
*. Do not change the script because you can loos all your data
*. DONE


ALTERNATIVE

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

Here it is the GitHub link:

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

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

GUILayout.Label("Remember that one thing about this variable!");
x = EditorGUILayout.IntField(whatever);

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

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/

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 :(

Thanks Loius, that's a very neat solution.

Similar to ShawnFeatherly, I use a custom [ReadOnlyAttribute] tag. It has a similar effect, but is non-editable and inline.

[ReadOnlyAttribute]
[SerializeField]
private new string Notes = "Don't forget to buy milk.";

Note that ReadOnlyAttribute is an extension that you have to manually add to your project

Hi Jethro, did you see my post about the Help property? It might help :) Feel free to help with the project at [UnityInspectorHelp][1] [1]: https://github.com/johnearnshaw/unity-inspector-help/

@usergame Just tried it, it's awesome. Thanks, have upvoted!

This is actually what i wanted to see possible, editable textfield i can add in some object in the scene to build a TODO list specific to scene. So it can’t be hardcoded in the C# file and has to be editable in editor.

I do use the UI Text but it has a bunch of useless information like rect transforms and font etc.