Rider insists on making Unity [Header] attributes inline

I have a very annoying issue where, whenever I create a Unity [Header] attribute and then put a field under it, Rider moves my field up onto the same line as the header.  This is very unintuitive and undesirable behavior for a header.  How can I stop this from happening?

0
4 comments

Hello Sy ,

Thank you for reaching Rider Forum.

It seems that it is required to tweak the settings in Settings | Editor | Code Style | C# > Arrangement of attributes > Place property/indexer/event/attribute on the same line option. 

All in all, if you face any bothering formatting rule, you may find it by following the instruction below: 

Configure formatting rules for selected code
 

0

Setting “Place field attribute on same line” to “Never” does fix this; but then all other attributes, like [SerializeField] are then placed on the line above, which is not desirable.

I would like a way to have attributes like headers appear above, while others are inline.

0

Hello Sy ,

Could you please share with me the code snippet where the issue is reproduced then? 

Examples of the desired and undesired formatting would help a lot. 

Looking forward to your response.

0

Expected/desired formatting:

        [Header("UI References")] 
        [SerializeField] private GameObject Example1;
        [SerializeField] private GameObject Example2;
        [SerializeField] private GameObject Example3;
        
        [Header("Other References")] 
        [SerializeField] private GameObject Example1;
        [SerializeField] private GameObject Example2;

Actual formatting:

        [Header("UI References")] [SerializeField] private GameObject Example1;
        [SerializeField] private GameObject Example2;
        [SerializeField] private GameObject Example3;
        
        [Header("Other References")] [SerializeField] private GameObject Example1;
        [SerializeField] private GameObject Example2;

Attributes which effectively apply to a group of fields should always be placed above; while attributes that are only applied to a single field should be inline by default.

0

Please sign in to leave a comment.