unity開發相關環境(vs、MonoDevelop)行結尾符不一致解決辦法

情景描述:最近在做Unity的網絡底層,用VS編寫源碼,MonoDevelop用來Debug,在Flash Builder上搭建的Python做協議生成器,期間有無數次Unity莫名奇妙的的down掉了,然後仔細分析了一下:

1、unity會爆出錯誤:

  There are inconsistent line endings in the 'Assets/...cs' script. Some are Mac OS X (UNIX) and some are Windows.

  This might lead to incorrect line numbers in stacktraces and compiler errors. Unitron and other text editors can fix this using Convert Line Endings menu commands.

2、monoDevelop在保存更改時也會報出編碼錯誤:

  The file "E:\BillGameframe\unity\...Netmanager\Netmanager.cs" has line endings which differ from the policy settings.
  Do you want to convert the line endings?

  

3、然後用Notepad++的“顯示所有字符” 查看文件,發現VS保存的文件每行以‘CRLF’結尾(window平臺文件),而MonoDevelop保存的是‘LF’結尾(Unix平臺)

4、然後用Unity新建c#文件,發現爲‘LF’結尾(Unix平臺)

  解決方案:

1、將unity新建文件改爲‘CRLF’

  將:C:\Program Files\Unity\Editor\Data\Resources\ScriptTemplates\下4個unity新建文件的模板改爲‘CRLF’,

  修改方法:用VS打開,在文件-高級保存選項-行尾 選擇window(CRLF);

  

2、修改MonoDevelop環境編碼:

  修改方法:Project-Solution Option-Source Code-Code Formatting- 下3個文件格式的Line endings都改爲Windows

  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章