Search Unity

Using a Custom C# DLL

Discussion in 'Editor & General Support' started by bobber205, Feb 21, 2010.

  1. bobber205

    bobber205

    Joined:
    May 12, 2009
    Posts:
    139
    What's the procedure for both scripting and Visual Studio Integration with regards to a custom DLL?

    I've written some networking code I would like to use in my project but I am not sure on how to start.

    Should I create a folder and paste the files? Or should I add it as a reference in Visual Studio and go about that route? I have the DLL built and have used it successfully in Visual Studio projects.

    Thanks for any help. ^_^
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    You can drop it into the assets folder and just use it.
    You might want to put it into the Assets/Plugins folder.

    But other than that you can just use it, given it only uses code that can be used at all (Mono 1.2.5 and the related frameworks and .NET 2.0)
     
  3. bobber205

    bobber205

    Joined:
    May 12, 2009
    Posts:
    139
    Thank you for the advice.

    I am now trying to include the Unity DLL in my regular project to do some testing and I am getting this error when attempting to call a function that has Debug.Log() in it.


    What did I do wrong? I have UnityEngine-Debug and non debug in my references as well as UnityEditor.

    I also have the required using UnityEngine;
     
  4. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    you can not use unity in a C# project

    you can only use custom C# dlls in unity given they are mono 1.2.5 compatible.
     
  5. bobber205

    bobber205

    Joined:
    May 12, 2009
    Posts:
    139
    Ah. This presents a problem which I'm sure can be solved.

    How can I write a wrapper for debugging that will print to the console when in a C# project and use Debug.Log() while in a Unity project?

    I would love to be able to do most of my debugging for certain classes in the full Visual Studio Environment and leave the Logging calls intact.

    Thanks. ^_^
     
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    by having distinct classes, don't see any other way as #if etc won't work
     
  7. bobber205

    bobber205

    Joined:
    May 12, 2009
    Posts:
    139
    Surely there must be a way. :(
    Distinct classes will never work. How do I compile my DLL with one certain class but then expect the code I am running to use another?
     
  8. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    simply, by having two projects in your solution and the project for C# and Unity usage use distinct classes
     
  9. chicolinohehe

    chicolinohehe

    Joined:
    Nov 1, 2011
    Posts:
    2
    Hi, for not open another topic i m use that =).

    I add external dll im my Unity project. In monoDevelop everything oks use the variables em methods and not erros in code,

    but when i play my project in Unity i recive the error..

    oops! Could not register window class : win32 error 0

    i use Mona for analyses my DLL's assembly and every check recive ok.

    what i make wrong. the dll is register in windows because your demo app works fine.

    Thanks for attention!!
     
  10. chicolinohehe

    chicolinohehe

    Joined:
    Nov 1, 2011
    Posts:
    2
    Hi, for not open another topic i m use that =).

    I add external dll im my Unity project. In monoDevelop everything oks use the variables em methods and not erros in code,

    but when i play my project in Unity i recive the error..

    oops! Could not register window class : win32 error 0

    i use Mona for analyses my DLL's assembly and every check recive ok.

    what i make wrong. the dll is register in windows because your demo app works fine.

    Thanks for attention!!