I want to use some NuGet packages inside Unity. I achieved that Unity finds the downloaded DLLs according to this article (https://www.what-could-possibly-go-wrong.com/unity-and-nuget/). The nuget.config file can be configured to download the packages into the Plugins folder inside the Assets folder. The Problem is that NuGet downloads multiple versions of each DLL (eg net46, netcore50, netstandard21, so forth) and Unity doesn't like multiple DLLs with the same name. I know I could simply put the DLL inside the Plugins folder by hand, but unfortunately that is not a solution which would please me.
Do you have any idea how I could work around this problem? Is it possible to configure NuGet to just download one DLL for each dependency?
Accessing the Package Manager window. To open the Package Manager window, navigate to Unity's main menu and go to Window > Package Manager.
NuGet is the package manager for . NET. NuGet is integrated into Visual Studio. However, Unity projects require a special process to add NuGet packages because when you open a project in Unity, its Visual Studio project files are regenerated, undoing necessary configurations.
Just thought I'd add this in case it helps anyone
I used the Nuget for Unity asset (free) to import a package (websocketsharp) and it was really easy and painless. The references in VS worked immediately as well
The package you're trying to import naturally has to be compatible with Unity but that's the same even if you import it manually. So I'd recommend giving this a try
Here are the details,
1. go to your desired NuGet package webpage.
2. on the right side **Download Package** option click it.
3. your package **.nupkg** file will be downloaded.
4. change its extension to .zip and extract it
5. go to lib and copy your package dll file from net or any netstandard folder. For [your unity project compatibility purposes][2] view this:
6. open unity workspace and create plugin folder
7. paste your dll file here.
Here is the video guide, i have imported newtonsoft.json pacakge in unity
You really don't wanna go down the path of configuring Unity to work with Nuget automatically. That article is rather old. With Unity 2018, you get a .net standard 2.0 compatibility level, which should be perfect for Nuget packages. Simply download the package using a separate VS project (as mentioned in the article), then take the netstandard20 version of the DLL and place it in your Unity project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With