[Unity] 如何建立 Dll?
Visual Studio Overview
1. 安裝 Visual Studio Community
2. 建立 Class Library 新專案
3. 將 UnityEngine.dll 加入參考
4. 設定 Target Framework
Mono Compiler Overview
1. 下載 Mono C# Compiler
2. 加入環境變數
3. 確認安裝版本與使用方法
4. Command Script
Visual Studio
1. 安裝 Visual Studio Community
首先當然是要先安裝 Visual Studio
除了免費外,它也提供了 Unity 專用的外掛
Visual Studio Tools for Unity
詳細步驟請點以上連結
2. 建立 Class Library 新專案
New Project => Visual C# => Class Library
3. 將 UnityEngine.dll 加入參考
在 Solution Explorer 的 Project 下右鍵 => 加入參考
UnityEngine.dll 的位置在安裝目錄的 Editor/Data/Managed 下
4. 設定 Target Framework
編譯前要到專案屬性頁下將 Target Framework 設定為 .Net Framework 3.5
(Solution Explorer 的 Project 下右鍵 => 屬性)
編譯專案為 Dll
程式都寫好之後
Ctrl + Shift + B 開始編譯專案吧!
編譯好的 Dll 會在 bin 資料夾下
Mono Compiler
1. 下載 Mono C# Compiler
2. 加入環境變數
3. 確認安裝版本與使用方法
4. Command Script
Example:
mcs src/*.cs -r:bin/Release/UnityEngine.dll -t:library -out:Hotter.dll
1. -r:reference,參考 UnityEngine.dll
2. -t:target,目標型態為 Library
3. -output:輸出名稱
歡迎您留言與分享!(Welcome for comments or sharing!)
- [Unity] 實作具選擇性開關的 Debug Logger
- [App剪報] 紀念碑谷:不只是遊戲!而是視覺 & 建築設計藝術品!(內含攻略影片)