Search Unity

MonoDevelop brackets format

Discussion in 'Getting Started' started by darthachill, Feb 15, 2015.

  1. darthachill

    darthachill

    Joined:
    Jan 25, 2015
    Posts:
    27
    A have problem with annoying formatting brackets. I found similar topics but I still haven't idea what option I need to change. I want to have format code like:
    Code (CSharp):
    1. if (isMage)
    2. {
    3.  
    4. }
    but monodevelop change it to:
    Code (JavaScript):
    1. if (isMage) {
    2. }

    How can I fix it ?
     
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,205
    Check under Tools -> Preferences -> Source Code -> Code Formatting -> C# Source Code. Additionally if it doesn't seem to be sticking, you may have to change the formatting policy for the solution under Project -> Solution Options -> Source Code -> Code Formatting -> C# Source Code.
     
    Kiwasi and darthachill like this.
  3. darthachill

    darthachill

    Joined:
    Jan 25, 2015
    Posts:
    27
    Thx you a lot I changed it and now it works. I have another question. When I create new script C# my brackets are always set in this kind.

    Code (JavaScript):
    1. public class GameInformation : MonoBehaviour {
    2.  
    3.     // Use this for initialization
    4.     void Start () {
    5.  
    6.     }
    7.  
    8.     // Update is called once per frame
    9.     void Update () {
    10.  
    11.     }
    12. }
    Is there any way to change it like before :) ?
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,205
    You'll need to modify the script template. On Windows they are under Unity/Editor/Data/Resources/ScriptTemplates.
     
    Kiwasi and darthachill like this.
  5. darthachill

    darthachill

    Joined:
    Jan 25, 2015
    Posts:
    27
    Thx you for answer, everything looks fine, but there is another problem. Where can I Set brackets
    Code (CSharp):
    1.            if (isMage)
    2.             {
    3.                 newPlayer.PlayerClass = new Mage();
    4.             } else if (isWarrior)
    5.             {
    6.                 newPlayer.PlayerClass = new Warrior();
    7.             }
    like these:
    Code (CSharp):
    1.            if (isMage)
    2.             {
    3.                 newPlayer.PlayerClass = new Mage();
    4.             }
    5.             else if (isWarrior)
    6.             {
    7.                 newPlayer.PlayerClass = new Warrior();
    8.             }
     
    Last edited: Feb 17, 2015
  6. wolga2

    wolga2

    Joined:
    Jul 4, 2012
    Posts:
    6

    @darthachill : Hi! I have exactly the same issue. But I am not able to fix it with the presented solution. Could you please tell me exactly how you did it? Thanks a lot!

    Wolga