gpt4 book ai didi

c# - 在 Visual Studio Code for Unity 中安装 Nuget 包

转载 作者:行者123 更新时间:2023-12-03 21:18:25 28 4
gpt4 key购买 nike

我想将我的关卡文件保存到 Unity Assets 文件夹中的 .json 文件中。由于JsonUtility的功能有限我想用Json.NET .我使用 Linux,所以我无法访问 Visual Studio,而是使用 Visual Studio Code。我想将包添加到我的 Unity 项目中,并从这里获取指南

Install a Nuget package in Visual Studio Code

首先我在终端中使用了这个命令

dotnet add package Newtonsoft.Json

但我收到了这个错误

error: Error while adding package 'Newtonsoft.Json' to project '/.../myUnityProject/Assembly-CSharp.csproj'. The project does not support adding package references through the add package command.



之后,我安装了 Nuget 扩展并将 Newtonsoft.Json@12.0.2 安装到我的项目中。提示我运行 dotnet restore以便能够使用该软件包。

这样做后我得到了这个错误

MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.



那么使用带有 Unity 的 Visual Studio Code 安装第三方工具的正确方法是什么?

最佳答案

不幸的是,由于 Unity3D 对 SLN 文件的粗暴操作,无法在 Unity 项目中使用 NuGet 包。

对于 Newtonsoft.Json,它可以在 Asset Store 免费获得,您可以从那里安装。

可以通过从 NuGet 网站下载 .nupkg 文件、提取 .NET 4.x 的 DLL 并将它们放在项目的 Assets 文件夹中来手动使用其他包。

但是,如果库包含 native 代码,您可能无法在每个平台上使用它。但是,如果您获得每个平台的 DLL,您可以在 Unity 编辑器中将它们设置为仅用于正确的平台。

关于c# - 在 Visual Studio Code for Unity 中安装 Nuget 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57746903/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com