c# - 如何将 Unity 支持添加到 NuGet 包?

标签 c# unity3d nuget

如何将包发布到支持 Unity(游戏引擎)的 NuGet?

此外,我是否需要安装 Unity 才能编译它,还是只针对特定的框架版本就足够了?

最佳答案

How do I publish a package to NuGet that supports Unity (the game engine)?

只需按照 the doc 中的说明进行操作即可. Unity3D 类库与常规 .NET 类库没有什么不同。它只是使用来自 Unity3D's fork of mono 的不同运行时.

Also, do I need to have Unity installed to compile it, or is targeting a specific framework version enough?

是的。如果您的库使用 Unity3D 类型,则项目需要从 Unity3D 引用程序集,例如 UnityEngine.dllUnityEditor.dll。如果您的库不使用 Unity3D 类型,您仍然需要使用 Unity3D 对其进行测试。因为较旧的 Unity3D 以 .NET 2.0 和 .NET 3.5 的子集为目标。因此,如果您的库使用仅在 .NET 4+ 中可用的功能,则它不适用于 Unity3D。另见 Using dll .

最好安装Visual Studio Tools for Unity3D for VS2015 (对于 VS2017,改为 install VSTU in the VS installer)然后您可以定位 Unity3D 目标之一:

Unity3D .NET targets

关于你包的发布,我觉得你最好publish your package on Unity3D asset store因为它是官方支持的。你可能想试试这个 improved version of Unity3D asset store tools将您的包发布到 Assets 商店时。

关于c# - 如何将 Unity 支持添加到 NuGet 包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43196608/

相关文章:

c# - 使用监督 Controller 模式时,我应该如何使用 Moq'd Views 对我的 WebFormMVP Presenter 进行单元测试

c# - 工厂模式、另一种模式还是根本没有模式?

ios - ARKit/ARFoundation 相机在一秒钟后卡住

c# - 如何调试从 TeamCity 部署的 nuget 包?

visual-studio - nuget 找不到资源 'productupdate/productupdatebar.xaml'

c# - 为什么必须在 foreach C# 中显式声明 ListItem

c# - 步行周期所需的代码? XNA Visual Studio C#

c# - unity 根据其他物体角度旋转物体

c# - 我如何像 bool 值那样翻转AudioListener.pause的值

NuGet v4 contentFiles 没有被复制到输出