用Unity2022在vs2019里創(chuàng)建腳本時(shí)遇到了CS8032
問(wèn)題
首先在Assets文件下創(chuàng)建一個(gè)名為CS8032WarningFixer的腳本
?
在腳本里輸入這些代碼?
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;
? ? }
}
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
打開(kāi)到你的工程文件夾下面,刪除xxxxxx.sln文件?
?關(guān)閉Unity重啟一下工程
?重啟后會(huì)看到生成了一個(gè)文件夾
重新打開(kāi)腳本后,警告消失了 。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-603583.html
?文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-603583.html
到了這里,關(guān)于Unity2022里用ViusalStudio2019創(chuàng)建代碼報(bào)錯(cuò)CS8032 C# 無(wú)法從 {1}: {2} 創(chuàng)建分析器實(shí)例 {0}。的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!