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.

Using external Libraries in Unity

Discussion in 'Scripting' started by levarg, Jun 13, 2016.

  1. levarg

    levarg

    Joined:
    Oct 6, 2015
    Posts:
    10
    Good day,

    I wrote my own .dll for Networking Operations that I now would like to use within Unity.
    But I'm not quite satisfied by adding a new Reference to each new MonoBehaviour Class I write.
    So, what's the best way to this? Is it even recommended?

    I used the Search, but I didn't find any post exactly describing my problem here.

    Edit: Since I'm bad at asking questions, here's the same question, rephrased:
    Did anyone ever use external Libraries in Unity over Visual Studio? If yes, how did you "install" them?
     
    Last edited: Jun 13, 2016
    SamFernGamer4k likes this.
  2. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
    What do you mean by "adding a new reference"? A code snipped showing the unsatisfactory bits would help.
     
    SamFernGamer4k likes this.
  3. levarg

    levarg

    Joined:
    Oct 6, 2015
    Posts:
    10
    I'm talking about the 'Add Reference' Option in the 'References' Dropdown Menu within Visual Studio, under the Solution Explorer.
     

    Attached Files:

    SamFernGamer4k likes this.
  4. jimroberts

    jimroberts

    Joined:
    Sep 4, 2014
    Posts:
    560
    We need more information. Is your library managed or unmanaged?
     
    SamFernGamer4k likes this.
  5. levarg

    levarg

    Joined:
    Oct 6, 2015
    Posts:
    10
    What's a managed Library? Maybe my missing knowledge about just those things results in giving too little information, sorry.

    All I (usually) do is Build my libraries into a shared folder where all my projects get them from. Since I normally just use MonoGame this is what worked best for me during development.
     
    SamFernGamer4k likes this.
  6. jimroberts

    jimroberts

    Joined:
    Sep 4, 2014
    Posts:
    560
    Are your libraries written in a managed language(C#) or an unmanaged language(C/C++/Rust)?
     
    SamFernGamer4k likes this.
  7. levarg

    levarg

    Joined:
    Oct 6, 2015
    Posts:
    10
    Thanks for clearing that up.
    Those libraries are all written in C#, using only the basic .NET System.* Namespace.

    Edit: I could try to rephrase my question:
    Did anyone ever use external Libraries in Unity over Visual Studio? If yes, how did you "install" them?
     
    Last edited: Jun 13, 2016
    SamFernGamer4k likes this.
  8. jimroberts

    jimroberts

    Joined:
    Sep 4, 2014
    Posts:
    560
    In your case you can simply put your managed .dll in \Assets\Plugins and add "using yourLibraryNameSpace;" at the top of your scripts.
     
    Last edited: Jun 13, 2016
  9. levarg

    levarg

    Joined:
    Oct 6, 2015
    Posts:
    10
    Thanks! That's just the answer I needed. Sorry for taking your time!
     
unityunity