keenanwoodall / Comment

Add comments to the inspector via a Comment attribute or component

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Comment

Add comments to the inspector via a Comment component, and a Comment tooltip attribute.

Component

Add the Comment component to write comments in the inspector.

image

Attribute

Instead of using [Tooltip] on a field, you can use [Comment] to automatically display the comment above a field as its tooltip

Unity_4khkk3yXne

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;
}

Attribute Limitations

  • 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

About

Add comments to the inspector via a Comment attribute or component

License:MIT License


Languages

Language:C# 91.9%Language:Java 5.3%Language:ANTLR 2.8%Language:Batchfile 0.0%