我正在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。
为什么代码无法编译?我是否缺少阻止其编译的内容?
答案 0 :(得分:0)