4.5 - Tooltip

    [AttributeUsage(AttributeTargets.Field, Inherited = true, AllowMultiple = false)]
    public class TooltipAttribute : PropertyAttribute
    {
        public readonly string tooltip;

        public TooltipAttribute(string tooltip);
    }

I know Unity loves fields, but lot of people actually uses Properties. Would it be that hard to flag your attribute has targeting both?

Properties aren’t shown in the Inspector, so what would be the point?

Hey, while we’re at it, can we make properties be shown in the inspector?

They are in some people’s computer… My Inspector also display methods. Should attributes shipped with Unity be reductive for no good reason or assume some people may extend the base behaviour far beyond what is “stock”?

(See the signature)

I had to create a new “Range” attribute because Unity’s one is “Field-only”. You can understand how annoying it is to have to convert your existing code to use a new attribute because the stock one has some weird restriction.
Don’t be so restrictive!

Oh, I see.

Well, pros and cons… it’s restrictive for you, but for people who don’t have an extended Inspector like yours, it helps to ensure they don’t put it on class members that it won’t work with. Is there a way to do both?

Sadly, not really… And hell I have searched for a way to change the AttributeUsage in Unity’s attributes. The code simply does not compile if an attribute is placed on the wrong item. (Ex.: Placing [Tooltip] on a property)

On the other hand, there’s no issue at placing an attribute on the wrong item if it doesn’t have the AttributeUsage restriction. It’s simply a wasted attribute if nothing looks for it. It’s why I say there’s no harm in allowing existing Unity’s attribute to support similar member type.

Some attribute makes sense to be limited to fields… Like [SerializedField]. Others - like [Tooltip] or [Range] - have a conceptual role of flagging data for how they are exposed to the user, which both Field and Property can be used for.

It’s why I had to rewrite a new attribute to replace Range;

[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class RangeValueAttribute : Attribute, IListAttribute

But it’s not “clean”. :frowning: