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