Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

C# Class Libraries (DLL) on a Mac?

Discussion in 'Scripting' started by Charles Hinshaw, May 18, 2008.

  1. Charles Hinshaw

    Charles Hinshaw

    Joined:
    Feb 6, 2008
    Posts:
    1,070
    I've Googled this, but found nothing.

    Is there a way to create C# class libraries (DLL) without Visual Studio .NET... a way to compile the byte code on a Mac?
     
  2. Charles Hinshaw

    Charles Hinshaw

    Joined:
    Feb 6, 2008
    Posts:
    1,070
    Ok, it looks like I can do this with MonoDevelop... I finally got a C# library to get created without the program freezing.
     
  3. bronxbomber92

    bronxbomber92

    Joined:
    Nov 11, 2006
    Posts:
    888
    this can be done via terminal when you compile the source you must specify the /target:library argument.
     
  4. Charles Hinshaw

    Charles Hinshaw

    Joined:
    Feb 6, 2008
    Posts:
    1,070
    I've not compiled C# via the terminal before. Can you expand on how to do this? I assume with Mono.


    I did manage to successfully create a DLL using MonoDevelop, but the likelihood of getting MonoDevelop to launch without crashing is pretty low.
     
  5. bronxbomber92

    bronxbomber92

    Joined:
    Nov 11, 2006
    Posts:
    888
    you would use it like this:

    gmcs [source] [-out:eek:utput name] [-r:referenced .dlls] [-target:your target]

    so... for example

    gmc -recurse:'./source/*.cs' -out:MyLib.dll -target:library -r:System.dll

    Something like that to build a directory of .cs files into a .dll


    Edit - Help menu from terminal:
     
  6. AngryAnt

    AngryAnt

    Keyboard Operator Moderator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Using the terminal or a shell script to compile a C# .dll library works for me with no hickups and its as easy as drag n' drop into your assets folder to use.

    My Path project uses a .dll.
     
  7. shaun

    shaun

    Joined:
    Mar 23, 2007
    Posts:
    728
    Is it possible to use the compiler included with Unity to create a MSIL assembly?

    I noticed that the "Assembly - CSharp - first pass.dll" seems to contain any non-compiled scripts that existed in the Plugins folder. When I disassembled the dll I found that it also contained the built-in image processing effects, which I guess is a problem. The "Assembly - CSharp.dll" was much cleaner however.
     
  8. AngryAnt

    AngryAnt

    Keyboard Operator Moderator

    Joined:
    Oct 25, 2005
    Posts:
    3,045
    Not sure. I did it externally using the mono compiler and Platypus to create a nice double-click solution. I set up Platypus to run the following shell script:
    Code (csharp):
    1. #!/bin/sh
    2.  
    3. cd "$1/../"
    4. echo Compiling...
    5.  
    6. gmcs -d:DEBUG -debug+ -r:/Applications/Unity/Unity.app/Contents/Frameworks/UnityEngine.dll -target:library -out:Path.dll Source/*.cs
    7. echo Distributing...
    8. cp -R -H "$1/../Path.dll" "$1/../Assets/Path/Path.dll"
    9. echo Done!
    Set the app to continue running after script completion and to have a textual output window.

    I also made a release version which doesn't define the DEBUG symbol and compiles with less debug information using the -debug parameter.

    Mono compiler: http://www.mono-project.com/CSharp_Compiler
    Platypus: http://www.sveinbjorn.org/platypus
     
  9. jitwtttl

    jitwtttl

    Joined:
    Aug 29, 2014
    Posts:
    8
    UnityEngine.dll is placed in /Applications/Unity/Unity.app/Contents/Frameworks/Managed/UnityEngine.dll on my mac.
     
  10. Mazyod

    Mazyod

    Joined:
    Apr 21, 2014
    Posts:
    25
    Location changed once more (Unity 5.4b18):

    /Applications/Unity/Unity.app/Contents/Managed/UnityEngine.dll