csharp 用于从csproj unity 2018中排除着色器文件的后处理器生成
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 用于从csproj unity 2018中排除着色器文件的后处理器生成相关的知识,希望对你有一定的参考价值。
using SyntaxTree.VisualStudio.Unity.Bridge;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
using UnityEditor;
using UnityEngine;
// Post processor for excluding shader files from the csproj unity 2018 generates
[InitializeOnLoad]
public class CsprojPostProcessor : MonoBehaviour {
static CsprojPostProcessor() {
ProjectFilesGenerator.ProjectFileGeneration += ModifyProjectFile;
}
private static string ModifyProjectFile(string name, string content) {
XDocument document = XDocument.Parse(content);
var itemGroups = document.Root.Descendants()
.Where(node => node.Name.LocalName == "ItemGroup");
IEnumerable<XElement> shaderGroups = itemGroups.Select(group => {
var child = group.Descendants()
.FirstOrDefault();
if (child != null && child.Name.LocalName == "None")
return group;
return null;
});
foreach(XElement group in shaderGroups) {
group?.RemoveAll();
}
return document.ToString();
}
}
以上是关于csharp 用于从csproj unity 2018中排除着色器文件的后处理器生成的主要内容,如果未能解决你的问题,请参考以下文章