Add comments to the inspector via a Comment component, and a Comment tooltip attribute.
Add the Comment component to write comments in the inspector.
Instead of using [Tooltip]
on a field, you can use [Comment]
to automatically display the comment above a field as its tooltip
public class SimpleExampleScript : MonoBehaviour
{
// This is a tooltip for a single line comment
[Comment] public float fieldWithComment;
/// <summary>
/// This is a summary description of the field.
/// </summary>
/// <remarks>
/// It is used to demonstrate how the [Comment] attribute handles documentation comments.
/// </remarks>
[Comment] public float fieldWithXMLComment;
}
- Comment discovery is greedy(?) The
[Comment]
attribute will always display the first comment block above the field in question, even if there's other fields in between.
// This is a comment
[Comment] public float field1;
[Comment] public float field2;
// ^ both fields will have the same tooltip