- Home /
Question by
Phazertron · Nov 16, 2020 at 11:05 PM ·
c#script.propertiesimprovement
Attributes (Tooltip, Range ...) for [SerializedField] Autoproperty
Hi,
I was looking for applying a [Tooltip(" ")] attribute to my fields when I bumped on my Autoproperty:
[SerializeField]
public float MouseSensitivity { get; private set; }
And I found that trying to attach further attributes it gives me the error:
CS0592 : Attribute 'Tooltip' is not valid on this declaration type. It is only valid on 'field' declarations.
As the error cleary state: "it's valid only on fields declarations" but is there some work around ? I mean, I found that lots of answers are pointing to a custom inspector but I was looking for some shortcuts.
Thank you
Comment
Answer by myzzie · Nov 16, 2020 at 11:14 PM
Something like this?
[SerializeField, Tooltip("")] private float mouseSensitivity;
public float MouseSensitivity => mouseSensitivity;