CSProjectFilePostProcessor.cs 1009 B

123456789101112131415161718192021222324252627282930313233
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Xml;
  4. public class CSProjectFilePostProcessor : AssetPostprocessor
  5. {
  6. // Add unsafe option to generated project file for Third Party assets that require it such as Easy Movie Texture.
  7. static void OnGeneratedCSProjectFiles()
  8. {
  9. if (System.IO.File.Exists("Assembly-CSharp.csproj"))
  10. {
  11. XmlDocument document = new XmlDocument();
  12. document.Load("Assembly-CSharp.csproj");
  13. XmlNodeList nodes = document.SelectNodes("//*[contains(@Condition, 'AnyCPU')]");
  14. foreach (XmlNode node in nodes)
  15. {
  16. if (node.Name == "PropertyGroup")
  17. {
  18. XmlElement element = document.CreateElement("AllowUnsafeBlocks", node.NamespaceURI);
  19. element.InnerText = "true";
  20. node.AppendChild(element);
  21. }
  22. }
  23. document.Save("Assembly-CSharp.csproj");
  24. }
  25. }
  26. }