还在坚持使用vs2022的同门可参考
vs版本2022.17.10.3
unity版本2022.3.34f1
et版本8.1 SHA-1: e1032638d6ea4d68dd549789fc734bcd31c08a91
警告之一:编辑ET.sln,发生警告 warning CS8032: 无法从 <编辑器安装路径>\Editor\Data\Tools\Unity.SourceGenerators\Unity.Properties.SourceGenerator.dll 创建分析器 Unity.Properties.SourceGenerator.PropertyBagGenerator 的实例: 未能加载文件或程序集“System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”或它的某一个依赖项。系统找不到指定的文件。
解决办法:新建unity/Assets/Editor/CS8032WarningFixer.cs
其中写入以下代码
using System.Linq;
using System.Xml.Linq;
using UnityEditor;
public class CS8032WarningFixer : AssetPostprocessor
{
private static string OnGeneratedCSProject(string path, string content)
{
var document = XDocument.Parse(content);
document.Root.Descendants().Where(x => x.Name.LocalName == "Analyzer")
.Where(x => x.Attribute("Include").Value.Contains("Unity.SourceGenerators"))
.Remove();
return document.Declaration + System.Environment.NewLine + document.Root;
}
}
保存,然后删除unity/*.csproj,在unity编辑器中打开C#项目自动重生成unity/*.csproj
再通过Vs2022打开ET.sln并编译,警告就不见了
警告之二:warning USG0001: Only allowed to have one file passed in with extension’.AdditionalFile.txt’
解决办法:ET.sln所在根目录新建.globalconfig文件
输入以下内容
is_global = true
dotnet_diagnostic.USG0001.severity = none
保存并关闭Vs和unity编辑器,重新打开编译ET.sln,警告就不见了