Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. using SyntaxTree.VisualStudio.Unity.Bridge;
  2. using System;
  3. using System.Linq;
  4. using System.Xml.Linq;
  5. using UnityEditor;
  6.  
  7. namespace VSTUHook
  8. {
  9. [InitializeOnLoad]
  10. public static class VSTUHook
  11. {
  12. static VSTUHook()
  13. {
  14. ProjectFilesGenerator.ProjectFileGeneration += Hook;
  15. }
  16.  
  17. static string Hook(string filename, string content)
  18. {
  19. var document = XDocument.Parse(content);
  20.  
  21. var metas = document.Root
  22. .Descendants()
  23. .Where(x => x.Name.LocalName == "Compile" || x.Name.LocalName == "None")
  24. .Select(x =>
  25. {
  26. var y = new XElement(x.Name.Namespace + "None");
  27. y.SetAttributeValue("Include", (string)x.Attribute("Include") + ".meta");
  28. return y;
  29. })
  30. .ToArray();
  31.  
  32. document.Root
  33. .Descendants()
  34. .Last(x => x.Name.LocalName == "None")
  35. .AddAfterSelf(metas);
  36.  
  37. return document.Declaration + Environment.NewLine + document.Root;
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement