Unity3d 플러그인 - managed plugins

Mobile Programming/Unity3d 2015. 4. 20. 20:43

plugin

managed plugins

http://docs.unity3d.com/Manual/UsingDLL.html

dll 로 외부 컴파일러로 빌드, 스크립트를 컴파일 하는 것도 가능. 프로젝트에 추가되어 어떤 다른 오브젝트든, 보통 스크립트처럼 사용 가능하다.

  • Unity 에서 제공하지 않는 언어로 개발된 바이너리 로드
  • Unity 코드를 소스제공 없이 이용할 수 있게 배포

Creating a DLL

  • .NET 코드를 생성하는 컴파일러를 선택
  • Unity API 를 사용하지 않는다면 컴파일러 옵션을 적절하게 선택하는 것만으로 DLL 을 생성
  • Unity API 를 사용한다면 Unity 자체의 DLL 을 컴파일러에서 사용가능하도록 만들어야한다.
Unity API
  1. mac

    • UnityEngine.dll / UnityEditor.dll
    • /Applications/Unity/Unity.app/Contents/Frameworks/Managed/
    • contextual menu (right click on unity) > Show Package Contents command
  2. windows

    • UnityEngine.dll / UnityEditor.dll
    • C:\Program Files\Unity\Editor\Data\Managed
  3. compile option example

    1. mcs -r:/Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEngine.dll -target:library ClassesForDLL.cs
    2. -r : included library path
    3. -target : build type
    4. (path) name
Tutorial
  1. Add Reference on Unity DLL

    1. mac (MonoDevelop)

      • References > Edit References > .Net Assembly tab > File System > select file.
    2. windows

      • References > Add Reference > Browse > select file
  2. Write DLL Code

  3. Using DLL in Unity
    1. copy builded dll into asset folder
  4. Setting UP Debugging
    1. mac
      • copy mdb into Assets/Plugins
      • Add-in Manager > Installed tab > Unity > select Mono Soft Debugger Support For Unity > Enable
    2. windows
      • pdb to mdb
      • Program Files\Unity\Editor\Data\Mono\lib\mono\2.0\pdb2mdb.exe