暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

BurstAssemblyDisable.cs 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #if UNITY_EDITOR
  2. using System;
  3. using System.IO;
  4. using UnityEditor;
  5. using UnityEngine;
  6. namespace Unity.Burst.Editor
  7. {
  8. /// <summary>
  9. /// Allow disabling of the Burst compiler for specific assemblies.
  10. /// ProjectSettings/Burst_DisableAssembliesForEditorCompilation.json
  11. /// ProjectSettings/Burst_DisableAssembliesForPlayerCompilation.json
  12. /// ProjectSettings/Burst_DisableAssembliesForPlayerCompilation_{platform}.json // if exists taken in preference to the one immediately above
  13. /// </summary>
  14. internal static class BurstAssemblyDisable
  15. {
  16. public enum DisableType
  17. {
  18. Editor,
  19. Player
  20. }
  21. private static string GetPath(DisableType type, string platformIdentifier)
  22. {
  23. if (DisableType.Editor == type)
  24. {
  25. return "ProjectSettings/Burst_DisableAssembliesForEditorCompilation.json";
  26. }
  27. var platformSpecicPath = $"ProjectSettings/Burst_DisableAssembliesForPlayerCompilation_{platformIdentifier}.json";
  28. if (File.Exists(platformSpecicPath))
  29. {
  30. return platformSpecicPath;
  31. }
  32. return "ProjectSettings/Burst_DisableAssembliesForPlayerCompilation.json";
  33. }
  34. public static string[] GetDisabledAssemblies(DisableType type, string platformIdentifier)
  35. {
  36. var pathForSettings = GetPath(type, platformIdentifier);
  37. if (!File.Exists(pathForSettings))
  38. {
  39. return Array.Empty<string>();
  40. }
  41. var settings = new BackwardsCompatWrapper();
  42. JsonUtility.FromJsonOverwrite(File.ReadAllText(pathForSettings),settings);
  43. if (settings == null || settings.MonoBehaviour == null || settings.MonoBehaviour.DisabledAssemblies == null)
  44. {
  45. return Array.Empty<string>();
  46. }
  47. return settings.MonoBehaviour.DisabledAssemblies;
  48. }
  49. }
  50. /// <summary>
  51. /// Settings file -
  52. ///
  53. ///{
  54. /// "MonoBehaviour": {
  55. /// "DisabledAssemblies":
  56. /// [
  57. /// "Example.Assembly"
  58. /// ]
  59. /// }
  60. ///}
  61. /// </summary>
  62. [Serializable]
  63. class BackwardsCompatWrapper
  64. {
  65. public BurstDisableSettings MonoBehaviour;
  66. }
  67. [Serializable]
  68. class BurstDisableSettings
  69. {
  70. public string[] DisabledAssemblies;
  71. }
  72. }
  73. #endif