Search Unity

VS [SerializeField] Formatting.

Discussion in 'Scripting' started by LordDarkon76, Aug 10, 2016.

  1. LordDarkon76

    LordDarkon76

    Joined:
    Apr 1, 2015
    Posts:
    22
    Hello, I use a lot [SerializeField] to show private variables at the inspector.

    When I run VR formatting it change a simple line.

    [SerializeField] private float something;
    [SerializeField] private int somethingElse;

    Into.

    [SerializeField]
    private float something;

    [SerializeField]
    private int somethingElse;


    Looking at the visual studio forums some users requested the change with a date of 2014,
    Is there a way that unity helps implementing this option?

    Kind Regards,
     
  2. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    If you have Resharper you can define if you want Field Attributes on the same line, or on a separate line.
    Its in "Code Editing > C# > Formatting Style > Line Breaks and Wrapping".
     
  3. LordDarkon76

    LordDarkon76

    Joined:
    Apr 1, 2015
    Posts:
    22
    Resharper is a paid 3rd party library, I know that it solves the issue, but its price doesn't worth that feature.
     
  4. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    decided to mention it, since i know natively VS does not expose that setting. There might be a other free extension that does so.

    Also ReSharper is pretty dam nice to work with, since i develop for a job i find it worth the cost, just for the inspections, and better code navigation and refactoring.