Personalizar arquivos de projeto criados pelo VSTUCustomize project files created by VSTU

As ferramentas do Visual Studio para Unity fornecem um retorno de chamada de estilo Unity durante a geração do arquivo de projeto.Visual Studio Tools for Unity provides a Unity-style callback during project file generation. Registre com o evento VisualStudioIntegration.ProjectFileGeneration para modificar o arquivo de projeto sempre que ele for gerado novamente.Register with the VisualStudioIntegration.ProjectFileGeneration event to modify the project file whenever it's regenerated.

DemonstraDemonstrates

Como personalizar os arquivos de projeto do Visual Studio gerados pelas Ferramentas do Visual Studio para Unity.How to customize the Visual Studio project files generated by Visual Studio Tools for Unity.

ExemploExample

#if ENABLE_VSTU
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;

using UnityEngine;
using UnityEditor;

using SyntaxTree.VisualStudio.Unity.Bridge;

[InitializeOnLoad]
public class ProjectFileHook
{
    // necessary for XLinq to save the xml project file in utf8
    class Utf8StringWriter : StringWriter
    {
        public override Encoding Encoding
        {
            get { return Encoding.UTF8; }
        }
    }

    static ProjectFileHook()
    {
        ProjectFilesGenerator.ProjectFileGeneration += (string name, string content) =>
        {
            // parse the document and make some changes
            var document = XDocument.Parse(content);
            document.Root.Add(new XComment("FIX ME"));

            // save the changes using the Utf8StringWriter
            var str = new Utf8StringWriter();
            document.Save(str);

            return str.ToString();
        };
    }
}
#endif

Confira tambémSee also

Exemplo: retorno de chamada de logExample: Log callback