用sublime text2寫unity3d c# script

最近開始摸unity3d,說不定下次就能參加game jam了?而不是老是只會玩些怪怪的冷門東西。

摸索的過程中,最讓我不能接受的就是那殘破的monodevelop了… 本身就很會當機,自動補完愛理不理。我最依賴的vi mode更是殘破不堪,連fF, text object都沒有還能稱作是vi mode嗎?所以我又花了些時間,在sublime text2上設定整套的c#開發環境…

首先,有幾個sublime text 2 plugin要裝:

  • CompleteSharp(C# autocomplete,這是有語意的補完)
  • Unity3D(語法highlight,原本的C# syntax highlight不太夠用)
  • Unity3D C# snippetupdate: 這個太雜亂了反而不好用
  • Unity3D Script Reference Searchupdate: 常常查不到,用dash取代
  • sublime-unity-complete(我忘記這有沒有作用了…感覺上沒有)
  • All Autocomplete

理論上可以把monodevelop的build system整合進sublime text 2,不過我沒有這麼作,目前用不到。

然後替你的unity project開啟一個sublime project, 設定檔寫上類似這樣的範例(假設"/Users/poga/MyProject/UGDE"是你的project path):

{
	"folders":
	[
		{
			"path": "/Users/poga/MyProject/UGDE"
		}
	],

    "settings":
    {
        "completesharp_assemblies": [
            // Unity本身的Script的dll
            "/Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEngine.dll",
            "/Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEditor.dll",
            "/Applications/Unity/Unity.app/Contents/Frameworks/Managed/nunit.framework.dll",
            "/Applications/Unity/Unity.app/Contents/Frameworks/Mono/lib/mono/unity/UnityScript.dll",
            "/Applications/Unity/Unity.app/Contents/Frameworks/Mono/lib/mono/unity/System.Core.dll",
            "/Applications/Unity/Unity.app/Contents/Frameworks/Mono/lib/mono/unity/System.dll",
            // 你自定義的Script編譯後的dll
            "/Users/poga/MyProject/UGDE/Library/ScriptAssemblies/Assembly-CSharp.dll",
            "/Users/poga/MyProject/UGDE/Library/ScriptAssemblies/Assembly-CSharp-Editor.dll",
            "/Users/poga/MyProject/UGDE/Library/ScriptAssemblies/Assembly-UnityScript-Editor.dll",
            "/Users/poga/MyProject/UGDE/Library/ScriptAssemblies/Assembly-CSharp-firstpass.dll"]

    }
}

這樣CompleteSharp就能正常處理C#的auto complete了

另外,由於sublime text 2內建的C# bundle頗舊了,因此請自己裝個https://github.com/craftstudios/csharp-sublime-text-2-package這份

最後記得在unity3d的preference中,將external tool的external script editor改成sublime text 2就搞定啦

Advertisements

用sublime text2寫unity3d c# script” 有 2 則迴響

迴響已被關閉。