如何将包发布到支持 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.dll
和 UnityEditor.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 目标之一:
关于你包的发布,我觉得你最好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/