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. Dismiss Notice

[SOLVED][CLOSED]About importing dll's

Discussion in 'Scripting' started by XukeLho, Apr 12, 2016.

  1. XukeLho

    XukeLho

    Joined:
    Dec 30, 2014
    Posts:
    199
    Hello,
    I'm working on an application (not a game) using Unity.
    I've tried to import the follow library https://netdxf.codeplex.com/ but I keep getting the error:

    "Error 2 The type or namespace name 'netDxf' could not be found (are you missing a using directive or an assembly reference?"

    Unity documentation says that in order to use a library, you just have to drop it in your Assets folder and all the references are created automatically, so I don't know what is going on.

    Any ideas?
     

    Attached Files:

  2. gheeler

    gheeler

    Joined:
    Nov 7, 2012
    Posts:
    18
    Try put them in a folder called Plugins in the assets folder
     
  3. XukeLho

    XukeLho

    Joined:
    Dec 30, 2014
    Posts:
    199
    Did that inside and outside of Plugins, right bellow Assets, and in some other structure
     
  4. Nigey

    Nigey

    Joined:
    Sep 29, 2013
    Posts:
    1,129
    Yeah normally you need to make a folder called, "Plugins" inside the Assets folder, and add any managed or unmanaged plugins in there. I notice you're using visual studio. When you add a dll into the plugins folder, it should automatically import into your visual studio project. So it's worth looking up your Reference in the Solution Explorer to make sure it's being imported by Unity.
     
  5. XukeLho

    XukeLho

    Joined:
    Dec 30, 2014
    Posts:
    199
    Yes, the reference its there on VS but it still doesn't work.
    It's all very strange :S
     
  6. Nigey

    Nigey

    Joined:
    Sep 29, 2013
    Posts:
    1,129
    Oh I just checked the download it's actually pretty simple. For some dll's they require the .pdb file as well for reference in Unity. Go to he .zip file again and drag both "netDxf.dll" and "netDxf.pdb" into the Plugins folder. I've tested this on my project and it works.
     
  7. XukeLho

    XukeLho

    Joined:
    Dec 30, 2014
    Posts:
    199
    I guess it kind of worked.
    But now I'm getting the error: "'Vector3' is an ambiguous reference between 'UnityEngine.Vector3' and 'netDxf.Vector3'"

    I'm assuming the DLL has a class called Vector3 and is creating conflicts with Unity's.
    Any idea on how to solve this?
     

    Attached Files:

  8. Nigey

    Nigey

    Joined:
    Sep 29, 2013
    Posts:
    1,129
    Well you'll just need to explicitly state which Vector3 you're after. So when you want a Unity Vector3, you'll say "UnityEngine.Vector3", and when you declare a netDxf Vector3 you'll need to explicitly call "netDxf.Vector3'". Like so:

    Code (CSharp):
    1.     private netDxf.Vector3 someDxfVector;
    2.     private UnityEngine.Vector3 someUnityVector;
    You can do things like give each namespace an alias to make it a bit quicker:

    Code (CSharp):
    1. using net = netDxf;
    2. using unity = UnityEngine;
    Then you can just do net.Vector3, and unity.Vector3.. But that's about as quick as you can make it with this.
     
  9. XukeLho

    XukeLho

    Joined:
    Dec 30, 2014
    Posts:
    199
    Alright! I guess I can mark this thread as answered.
    I just hope this library has what I need.

    Thanks for the help Nigey
     
    Nigey likes this.