The namespace name #39;SyntaxTree#39; could not be found(找不到命名空间名称语法树)
问题描述
我正在Unity 2019.2.3f1中开发。我正在尝试编写一个可以Customize project files created by VSTU的脚本。为了防止链接被删除,我提供了一个与链接中的脚本非常相似的脚本。
#if ENABLE_VSTU
using System.IO;
using System.Text;
using System.Xml.Linq;
using UnityEditor;
using SyntaxTree.VisualStudio.Unity.Bridge;
[InitializeOnLoad]
public class ProjectFileHook
{
private class Utf8StringWriter : StringWriter
{
public override Encoding Encoding => Encoding.UTF8;
}
static ProjectFileHook()
{
ProjectFilesGenerator.ProjectFileGeneration += (string name, string content) =>
{
// parse the document and make some changes
XDocument document = XDocument.Parse(content);
document.Root?.Add(new XComment("FIX ME"));
// save the changes using the Utf8StringWriter
Utf8StringWriter str = new Utf8StringWriter();
document.Save(str);
return str.ToString();
};
}
}
#endif
问题是,由于错误error CS0246: The type or namespace name 'SyntaxTree' could not be found (are you missing a using directive or an assembly reference?),using SyntaxTree.VisualStudio.Unity.Bridge;无法编译。
我已检查Unity和Visual Studio是否已安装并启用Visual Studio Tools for Unity。
为什么代码无法编译?我是否遗漏了阻止它编译的内容?
推荐答案
以防其他人遇到此问题。
此问题是由脚本位置引起的。脚本必须位于Editor文件夹下,否则脚本不会按预期工作。
感谢therealjohn指出here。
这篇关于找不到命名空间名称语法树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:找不到命名空间名称语法树
基础教程推荐
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
