Unity 在项目文件生成期间提供回调。 使用 AssetPostprocessor
实现 OnGeneratedSlnSolution
和 OnGeneratedCSProject
方法,以在重新生成项目或解决方案文件时对其进行修改。
演示
如何自定义由 Visual Studio Tools for Unity 生成的 Visual Studio 项目文件。
示例
using System;
using UnityEditor;
using UnityEngine;
public class ProjectFilePostprocessor : AssetPostprocessor
{
public static string OnGeneratedSlnSolution(string path, string content)
{
// TODO: process solution content
return content;
}
public static string OnGeneratedCSProject(string path, string content)
{
// TODO: process project content
return content;
}
}