Search Unity

  1. Unity 2020.2 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Code Formatting

Discussion in 'Scripting' started by deadswine, Aug 6, 2012.

  1. deadswine

    deadswine

    Joined:
    Mar 27, 2012
    Posts:
    19
    Please point me to some good editor with code formating and code completition for unityscripy.
     
    Last edited: Aug 6, 2012
  2. renman3000

    renman3000

    Joined:
    Nov 7, 2011
    Posts:
    6,534
    Monodevelop.
    It comes withnUnigy.


    Just open a script from with in the editors, project panel.
     
  3. deadswine

    deadswine

    Joined:
    Mar 27, 2012
    Posts:
    19
    I'am aware of monodevelop but its not formatting javascript code at all
     
  4. BlackMantis

    BlackMantis

    Joined:
    Feb 7, 2010
    Posts:
    1,475
    What aspects of formatting are you looking for?

    Most editors that have auto formatting require that you write single lines, then they collapse.

    Code (csharp):
    1.  
    2. //Black Mantis code fu style
    3.  
    4. var abc : String;
    5. //----------------------------------------------------//
    6. funtion Start() {
    7.     //------------//
    8.     abc = "Hello";
    9.     //------------//
    10. }
    11. //----------------------------------------------------//
    12. function Update() {
    13.     //------------//Comments
    14.     if(Input.GetKey("p")) {
    15.       print(abc + "ObjName = " + name);//Comments
    16.     }
    17.     //------------//
    18. }
    19. //------------------------------------------------------//
    20.  
    Using the space between blocks makes it real easy to find something or separate unrelated blocks

    I went through so many styles, but like this the most. On a huge script I will try to break format to make things easier to find.
    (eg)

    Code (csharp):
    1.  
    2. if(index==0) { print("DoSomethingDifferent"); }
    3. else if(index==1) { print("DoSomethingDifferent"); }
    4. else if(index==2) { print("DoSomethingDifferent"); }
    5. else if(index==3) { print("DoSomethingDifferent"); }
    6. else if(index==4) { print("DoSomethingDifferent"); }
    7. else if(index==5) { print("DoSomethingDifferent"); }
    8.  
     
    Last edited: Aug 6, 2012
unityunity