【发布时间】:2019-10-30 09:22:53
【问题描述】:
我正在 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
问题是,using SyntaxTree.VisualStudio.Unity.Bridge; 编译失败,因为错误error CS0246: The type or namespace name 'SyntaxTree' could not be found (are you missing a using directive or an assembly reference?)。
我已检查 Unity 和 Visual Studio 是否已安装并启用 Visual Studio Tools for Unity。
为什么代码编译失败?我是否遗漏了阻止其编译的内容?
【问题讨论】:
-
根据forum.unity.com/threads/syntaxtree-missing-reference.384423,您只需要添加visual studio代码编辑器包...因为我无法通过公司防火墙使用包管理器的资产存储,我无法为您测试它
-
@BugFinder 恐怕这个解决方案不起作用。
标签: c# visual-studio unity3d namespaces visual-studio-2019