Search Unity

Publishing content to the asset store, using dll files

Discussion in 'Editor & General Support' started by roamcel, Sep 15, 2011.

  1. roamcel

    roamcel

    Joined:
    Sep 15, 2011
    Posts:
    17
    I was unable to find information about this: in the process of submitting a new asset to the asset store, the guidelines talk about the use of Unity's relevant tool to build the package that will be distributed, however if I understand correctly this means that the whole source of the asset scripts become open to the end user?

    In consideration of my particular project, besides the risk of code manipulation and consequent illegitimate requests of support, this possibility creates other unpleasant scenarios which can compromise the original work and its evolutions, so I checked the asset store and noticed that many packages offer their content in standard c or javascript files -accompanied by one or more .dll files-

    It is quite clear that these .dll files act as libraries that the project references... but I'm at a loss at how to produce them.
    Do you need visual studio or similar to code them into a dll, and then use 'declare', 'extern' and such in your unity application, or is there a more streamlined way of doing this, perhaps directly through unity? The former method actually feels like reinventing the wheel since you obviously have to replicate data structures for communication between the library and the project?

    Please help me understand how you create the dlls that encapsulate your asset's methods. Of course my intention is to encapsulate the critical functions only, those that can break hell loose if wrongly manipulated by the user.

    Thanks.
     
    Last edited: Sep 15, 2011
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    Hey Roamcel,

    You can build the DLL in monodevelop quite easily. What you do is just go to the project settings and change where the built binary is exported then do a build from mono develop. Grab the DLL and you can use that.

    One caveat though is if it is an editor extension you need the window classes to exist outside the dll. Download strumpy shader editor and have a look at how the dll and window classes are laid out if you are curious about how to do this.
     
  3. roamcel

    roamcel

    Joined:
    Sep 15, 2011
    Posts:
    17
    Thanks a lot for the straight forward explanation!
     
  4. roamcel

    roamcel

    Joined:
    Sep 15, 2011
    Posts:
    17
    I tried to follow what you suggested but I'm at a loss. I was able to change the destination folder for the build, but the dll wounds up named 'Assembly-CSharp.dll' regardless of what I do. Am I supposed to just rename this file and drop into unity? Besides, the build output shows that ALL the project scripts get added to that 'assembly-csharp.dll' file, included the new file I made which contains the window class call, like in strumpy shader editor.

    Please explain the process better.

    Thanks.
     
  5. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    1,191
    Not positive, as I'm just learning about DLL's myself, but you might try (or others might try, since this thread is quite old) placing your code in a namespace, I.e.

    Code (csharp):
    1. namespace MyNamespace{
    2. Code
    3. }
    Use the same namespace in all of your scripts.
     
  6. goodbadwolf

    goodbadwolf

    Joined:
    Feb 24, 2013
    Posts:
    2
    http://docs.unity3d.com/Documentation/Manual/UsingDLL.html has a detailed set of steps on how to build and use a DLL.