How do I publish a package to NuGet that supports Unity (the game engine)?
Also, do I need to have Unity installed to compile it, or is targeting a specific framework version enough?
To add a Unity package to your project, follow these steps: In your Unity development environment, open the Project tab. In the left pane of the Project tab, right click the Assets folder, then select Import Package → Custom Package… in the context menu. An Import package…
Accessing the Package Manager window. To open the Package Manager window, navigate to Unity's main menu and go to Window > Package Manager.
How do I publish a package to NuGet that supports Unity (the game engine)?
Just follow the instructions in the doc. Class library for Unity3D is nothing different from regular .NET Class library. It just uses a different runtime comes from Unity3D's fork of mono.
Also, do I need to have Unity installed to compile it, or is targeting a specific framework version enough?
Yes. If your library uses Unity3D types, the project needs to reference assemblies, such as UnityEngine.dll
and UnityEditor.dll
, from Unity3D. If your library doesn't use Unity3D types, you still need to test it with Unity3D. Because older Unity3D targets .NET 2.0 and a subset of .NET 3.5. So if your library uses features only available in .NET 4+, it won't work with Unity3D. See also Using dll.
It's better to install Visual Studio Tools for Unity3D for VS2015 (for VS2017, install VSTU in the VS installer instead) and then you can target one of the Unity3D targets:
As for the publishment of your package, I think you'd better publish your package on Unity3D asset store since it is officially supported. You may want to try this improved version of Unity3D asset store tools when publishing your package to the asset store.
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