BuildHelpers.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Xml;
  7. using System.Xml.Linq;
  8. using UnityEditor;
  9. using UnityEditor.Build;
  10. using UnityEditor.Build.Reporting;
  11. using UnityEngine;
  12. namespace UnityEditor.XR.Management
  13. {
  14. internal static class BuildHelpers
  15. {
  16. internal static void CleanOldSettings<T>()
  17. {
  18. UnityEngine.Object[] preloadedAssets = PlayerSettings.GetPreloadedAssets();
  19. if (preloadedAssets == null)
  20. return;
  21. var oldSettings = from s in preloadedAssets
  22. where s != null && s.GetType() == typeof(T)
  23. select s;
  24. if (oldSettings != null && oldSettings.Any())
  25. {
  26. var assets = preloadedAssets.ToList();
  27. foreach (var s in oldSettings)
  28. {
  29. assets.Remove(s);
  30. }
  31. PlayerSettings.SetPreloadedAssets(assets.ToArray());
  32. }
  33. }
  34. }
  35. }